=^.^=

/bin/rm: Argument list too long

karma

You may encounter this error when deleting all the files in a given directory:

/bin/rm: Argument list too long

This happens because you can only pass 128K of command line and environment data; doing an rm * first fills that buffer with all of the filenames in the given directory.

The solution is to feed the contents of the directory to rm one-by-one:

find ./path/ -print0 | xargs -0 rm

Comments

• Thetehcomputerlad

Thanks, Was just what I was looking for, Just could not remember the syntax...

One note tho, To avoid it from removing directories, such as if you ran: find ./path/ -print0 | xargs -0 rm -rf (with the rf flags) on accident, As I almost did :D

You can add in the type flag to find, as:

find ./path/ -type f -print0 | xargs -0 rm -rf

Just throwing it out there...

• Rao

Cool...this works great...