Add to Favourites Add to Favourites    Print this Article Print this Article

Cannot delete oversized directories: /bin/rm: Argument list too long

If you're trying to delete files inside a directory and the following command is not working

/bin/rm -rf *
/bin/rm: Argument list too long.

Try this instead:

find . -type f -delete

The find command is much quicker at listing files from a directory, and newer versions of "find" have -delete built in, which will allow you to remove files very quickly.

Another solution, reportedly even faster than "find" is to use perl:

perl -e 'for(<*>){((stat)[9]<(unlink))}'

to delete all files in the current directory.   I don't believe it knows what the difference is between a file and a directory, so if you have sub-directories, it will probably throw some errors, but in theory, shouldn't remove them.

Was this answer helpful?

Also Read