Today I’ve decided to cleanup the hard drive on my Linux workstation and “surprisingly” found 8G of temporary files in one folder.

After quick review I’ve decided to erase them with rm command.

For my surprise when running the command:

/bin/rm *.tmp

I got following error message:

bash: /bin/rm: Argument list too long

Conclusion:Even rm command has his limits!

Solution: Get Plumber(Joking)
Actually only Pipe is needed.
By typing following command:

find . -name "*.tmp"|less

You will see list of the files and by replacing less with xargs /bin/rm those files will be erased. Can you skip previous step? Yes you can and it is not required, but you risk to erase a lot of data if you have syntax error.

find . -name "*.tmp"| xargs /bin/rm


find . -name "*.tmp" -print0 | xargs -0 /bin/rm


find . -name "*.tmp" -delete

if you have space in file name.
Depending on the number of files and your system speed after a while all files will be erased.

Done .


(Siby) If you get Argument list too long on all commands – probably you should look at you .bashrc file.
More specifically at PATH. Did you modify it to look at subfolders?


I’m adding information from the comments to main post. Thanks to “Scriptster” and “Swynndla”



Another solution is to use -delete option applied to find command.


14 Responses to “bash: /bin/rm: Argument list too long – How to fix it (Update 2 )”

  1. nap on November 5th, 2009 9:26 am

    thank you very much, helpul command, helps me a lot!

  2. Swynndla on December 15th, 2009 10:41 pm

    If some of your filenames have spaces in them then the above wont work, so do this instead:
    find -name “*.tmp” -print0 | xargs -0 /bin/rm

  3. Gopikrishna on February 18th, 2010 5:42 am

    Thanks a lot. Helpful command.

  4. Ali on August 10th, 2010 5:59 am

    It works. Thanks

  5. Tudor on February 11th, 2011 10:31 am

    find . -name ‘sess_0*’ | xargs rm

  6. Scriptster on October 3rd, 2011 3:56 pm

    For a less discriminate deletion of EVERYTHING in the directory one can just use ‘ls’ command with -rf keys to delete any directory that may come up in the listing:

    ls | xargs rm -rf

    BE VERY CAREFUL USING IT!!! Run in a wrong location this will destroy your system!

    Also, in your post, it’s best to remove the period (.) from the end – it should not be in the executed command:

    find . -name “*.tmp”| xargs /bin/rm (no period at the end)


  7. Naresh on April 9th, 2012 2:51 am

    Thanks a lot. This helped me…..

  8. PoorMe on April 10th, 2012 6:41 am

    I’ve just lost all of my files and folders on my server in just 2 seconds while trying to find the right use for my situation!

    I think you should seriously warn visitors before using this command. They might not lose a lot of data. They might lose everything!!!

    Thanks anyway!

  9. hb on April 12th, 2012 9:10 pm

    Actually the warning is there as you can see first I use less to check the files that are in the list…

  10. samudram on May 30th, 2012 9:08 am

    Thank a ton… This helps big time… 🙂

  11. Parul Mehta on July 27th, 2013 7:51 am

    Thanks a lot , it worked for me !!

  12. Siby on April 28th, 2014 2:13 am

    Hi all..

    I am getting an error message “Argument too long” in the fedora 17 OS.
    ls, mv, rm -f, rm -rf, su etc nothing working at all.
    These are the details of output which i am getting:
    [cpl@cpl ~]$ ls
    bash: /usr/bin/ls: Argument list too long
    [cpl@cpl ~]$ pwd
    [cpl@cpl ~]$ su
    bash: /usr/bin/su: Argument list too long
    [cpl@cpl ~]$ ls
    bash: /usr/bin/ls: Argument list too long
    [cpl@cpl ~]$ mkdir 1
    bash: /usr/bin/mkdir: Argument list too long
    [cpl@cpl ~]$ pwd

    Pls do the needful
    Thanks in advance..!

  13. hb on August 1st, 2014 12:41 pm

    You should check your .bash file

  14. Joshua Brings on January 9th, 2018 1:58 am

    You can try using the Long Path Tool. It can fix filename too long, path too long or even access denied issues.

Leave a Reply

You must be logged in to post a comment.