Chill out!!

Friday, October 07, 2005

Argument list too long - Work Around

I was deleting files by using rm on the linux server. There is a maximum number of files that can be passed as arguments to rm. So it does not allow you remove the files with 'rm' command.

Using rm to delete files is the easiest way adopted by us (linux users). rm is generally used with ease on a daily basis. So what you can do when the simple rm command does not work.

There were around 72K files were generated in a folder which I wanted to delete this morning. So I went to that directory and tried to remove all the files starting with "Count*".

root # rm Count*
/bin/rm: Argument list too long.

No way. The irritating error message appeared.

Not sure what the maximum number of arguments for rm command, may be its 1024 arguments only.

The workaround is simple: Use find to pipe all the matching files to rm, one at a time.
root # find . -name 'Count*' | xargs rm

And this can remove as many files as you want. This work really great!!

1 Comments:

  • I really enjoyed the content on your blog about software testing will be back very frequently! I actually have my own software testing exposed blog with all kinds of stuff in it. You�re welcome to com by

    By Blogger Weedlet, at 8:54 AM  

Post a Comment

<< Home