Helm's Technology Blog

rm Argument list too long.. Linux Huh? moment.

by admin on Jun.17, 2009, under Server

I recently had a little problem when deleting a store of spam e-mails off one of my personal servers.

Basically entering the standard death defying command of “rm -Rfv *” while in a directory (this will delete everything recursively – have fun), the system responded “Argument list too long” – cue the first “huh?” moment – I’ve used the command for years and years, never had a problem.

I did “man rm” to check I hadn’t had a “moment” and forgotten how to use it – nope.. . A little trawling came up with several people with the same problem but no really practical solutions.  The problem occurs when you have too many files for the built in systems used by the rm command in the kernel – these are pretty old so have some limits that you don’t expect! – you can do this:

rm -Rfv a* then rm -Rfv A* –  these deletes all files starting with a or A etc.. – very long and rather silly – so after thinking and thinking and muttering an old command came to mind :)  using a combination of find and xargs you can pipe a file on at a time so here we go – my favoured solution:

find . -name * | xargs rm -fv

This works fine – I suspect it will have a limit somewhere, but my server hasn’t hit it yet!

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • MySpace
  • StumbleUpon
  • Technorati
  • TwitThis
:, , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!