/bin/rm: Argument list too long.
After forgetting to add “2>&1″ to the end of my cron job that runs every minute I ended up with a lot of “mail” in my Maildir, about 600,000! So I thought that I could do a simple “rm 11*” (Each file started with a 11)
But I ran into a problem: “Argument list too long.”
So after researching this problem I found out why (It has to do with not being able to fit the supplied argument list and environment into the 128K buffer)
I also found a solution: find . -name ‘11*’ | xargs rm
Three minutes later my Maildir was clear!
Regards,
Steven Roddis
Anonymous said,
October 9, 2006 @ 4:32 pm
find . -name ‘11*’ -exec rm “{}” \;
Vinay said,
November 23, 2006 @ 4:59 pm
Hi,
i want to delete all webalizer stats of my server. will this command work for this:
find . -name ‘/home/*/tmp/webalizer/*’ | xargs rm
Please let me know.
Regards,
Vinay
Steven Roddis said,
November 24, 2006 @ 1:10 pm
Yes, but it won’t delete the directories.
Dipu said,
January 5, 2007 @ 5:50 am
I feel using exec from find command is bound to fail since the argument list will be too long for it to handle.
From somewhere else on net.
getconf ARG_MAX gives the maximum number of arguments that commands can take…
Jeff said,
January 6, 2007 @ 4:45 am
Dipu, exec works because find passes the filenames one at a time.
Sadanand said,
October 14, 2007 @ 8:56 pm
This helped me a lot. Thanks
Stephen said,
January 3, 2008 @ 8:05 am
To touch on the issue Vinay raised, I had to use the -wholename option on the find command to delete files from multiple directories. The following got rid of all the incomplete files in my audio stream directories quite nicely:
find /usr/local/Streams/ -wholename ‘*/incomplete/*’ -print0 | xargs -0 rm -f