Tuesday, December 04, 2007

rm: Argument list too long

I found out that I made a stupid mistake in a script I am running on a Linux box, the result of this was that there was send a e-mail to my mailbox every 5 minutes so after correcting the mistake I wanted to clean the junk in my Mailbox dir by simply deleting all the messages that where out there. However when issuing the rm command the system presented my with the following error message:

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

I found a great article on moundalexis.com (http://www.moundalexis.com/archives/000035.php). The solution to the problem was simply do a find and pipe it to xargs rm

find . -name '*gingerale.dreamhost.com'| xargs rm

This solved my problem of having 30270 files in a single location and the need of removing them without to much hassle.


1 comment:

Radek said...

My way is

find ./ -name '*gingerale.dreamhost.com' -exec rm {}; \

I have to say that I found you blog really quality. Well done, I really like your python posts.
Best Regards

Radek