bash: /bin/rm: Argument list too long

Yesterday I was trying to delete rather a lot of files from a server that had been used as a spam relay.

There were a total of 2.2 million files in the /var/spool/mqueue folder (and another 2 million in the /var/spool/clientmqueue folder!).

If you try to delete this many files from a folder using …

rm -f *

… you get get the following error

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

The easiest way round this is to use find and pipe the results to xargs command.

Try the following -

find . -P -H -name '*' | xargs rm -f

Use the -P and -H so that your find command doesn’t go off following links and make sure that your wildcard (*) is enclosed in single quotes or you’ll still run into problems.

Last updated by .




Related posts:
  1. Modifying subinacl exports with a bash script
  2. Installing UK voice prompts for Asterisk



SysAdminMan provides virtual PBX hosting based on Asterisk and Freeswitch.
Avaialble systems include FreePBX, PBX-in-a-Flash, Elastix, A2Billing and FusionPBX.
More details and prices can be found at sysadminman.net


Leave a comment