Press "Enter" to skip to content

Argument list too long when using rm ?

Ever needed to delete a lot (and I mean several thousand) files from a directory in Linux? Then you may have encountered the “Argument list too long” error message which occurs when using “rm *” on the folder. This problem occurs because the list of files exceeds the 128K buffer which the kernel uses to pass the list of files to rm .

So how to defeat this problem?

Simple, use:
find . -name "*" -print | xargs rm
or, if you just want to delete the files starting “unwantedMail”, then use:
find . -name "unwantedMail*" -print | xargs rm

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.