Linux File Removal Error: Argument list too long

Published by Torry Crass on

When you run a removal command in Linux with the recursive and force options enabled (rm -rf *), you don't expect to get back a failure message.  After all, YOU FORCED IT!  However, it just so happens that even with force, you can encounter a situation where the list of files you're deleting is simply too long for the rm command to process.  In that case, you'll receive the following:

[root@hostname mqueue]# rm -rf *
-bash: /bin/rm: Argument list too long

In this instance, it was a mail queue that had a ridiculous number of messages in it.

To get around this nasty message, in steps xargs allowing for the following command:

ls | xargs rm

The cursor is blinking green, the directory is clean.


0 Comments

Leave a Reply