Crucial Paradigm

Call us now 1300 884 839

Member Login
Australia USA

Location: Australia

Crucial Paradigm Australia Official Blog

RSS Feed

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

June 1, 2010

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

Aaron Weller
Author:


(2) Comments

2 Responses on this topic

  1. 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

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

    find . -exec rm {} \;

Leave a Reply

Copyright 2003-2012 © Crucial Paradigm Pty Ltd, All Rights Reserved