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


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » System Level » File System

Cannot delete oversized directories: /bin/rm: Argument list too longLast Modified: Jun 4, 2015, 5:27 pm
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.

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST