I gave the command rm *, but I got the following error:
/bin/rm: Argument list too long.

The directory has lots files that I want to delete. How can I do it?
- Rob

The reason for the error is that in shell when you mention a *, your shell actually expands that * and puts all the filenames there and since length of the command line is limited, you end up getting argument list too long error.

To remove all the files, you can do any one of the following:

  • You can remove the whole directory and recreate the directory.
  • Use find . -exec rm {} \;
  • Use find . -name '*' | xargs rm

Leave a Reply