How to delete files when you encounter: -bash: /bin/rm: Argument list too long

If you have tried to empty any large folders, such as mailbox directories or temporary folders on a linux server you will probably encountered the following error:

-bash: /bin/rm: Argument list too long

An easy way around this is to use the following command (this will remove all files in the folder you run this command):

find . | xargs rm

If you want to delete files with a specific string in them, you can do with the following:

find . -name ‘*string*’ | xargs rm




  • Actually that command can be dangerous when filenames contain spaces, or non ascii characters, to be sure that the operation works properly you should tell find to use null line endings, and xargs to use them too.

    find . -print0 | xargs -0 rm

  • Or better yet, do it in one command without xargs…

    find . -exec rm {} \;