Posts Tagged ‘system’

inux: rm and the ‘Argument list too long’ error message.

January 6th, 2010

Linux: rm and the ‘Argument list too long’ error message.

Linux: rm and the ‘Argument list too long’ error message.


Let’s say you wanted to delete all the files in a directory that begins with the word ’spam’:

[root@yoursite filter]# rm spam*

bash: /bin/rm: Argument list too long

ERROR!

This happens when you are trying to delete too many files in a directory at the same time – it seems rm has limits ….

To solve the problem:

Use ‘find’ to pipe all the matching files to ‘rm’, one at a time.

[root@yoursite filter]# find . -name ’spam*’ | xargs rm

» Read more: inux: rm and the ‘Argument list too long’ error message.