/bin/rm: Argument list too long


You type: rm * -f
You get: /bin/rm: Argument list too long
Reason: in shell when you do * after rm and get Argument list too long, your shell actually expands that * and puts all the filenames after rm and since length of the command line is limited, you end up getting argument list too long.

Possible solutions:

  1. You can remove the whole directory and recreate the directory
  2. When 1 is not an option, you can you “find” to delete for you. I actually use this method more often then removing/creating directory.
    find . -exec rm {} \; This will delete everything in current directory on. Be careful with this command since you could potentially delete things you may not wanted to. I suggest running find . |more first to see what will be affected.  To read more about find see:  man find

————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.


2 Responses to “ /bin/rm: Argument list too long ”

  1. July 27th, 2008 | 4:41 am

    [...] La solución que más me ha convencido y que al final he acabado utilizando ha sido la que puede encontrarse en esta página. [...]

  2. May 10th, 2011 | 3:32 am

    из консоли ls -l /usr/local/vpopmail/domains/oldcomp.ru/abuse/Maildir/cur/ | awk ‘{print “rm /usr/local/vpopmail/domains/oldcomp.ru/abuse/Maildir/cur/”$9}’ | /bin/sh

    удаляет все !!!

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image