"Argument List Too Long" Workaround

September 25, 2006 at 8:18 am

Sometimes when performing a remove on a long list, you’ll get the error “Argument list too long”. For example, I have a script that pollutes the /tmp directory with msg-11* directories (perl MIME::Parser directories). Obviously I should clean this up, but I also needed a way to delete all these directories. The best way is to use a combination of xargs, find and rm.

For example:
find . -name ‘msg-11*’ | xargs rm -r