[nycbug-talk] Deleting Lots of Files.
fungus at aros.net
Wed Jun 21 14:19:27 EDT 2006
On Jun 21, 2006, at 8:44 AM, Hans Kaspersetz wrote:
> I was wondering what the best way to delete lots of files is. Here is
> my problem, I have a mail box directory with 55K files in it. The
> names are in the form: 1144126802.V411I59451aM517953.foo.com:2, They
> are semi squential.
> I would like to delete all the files in the 114* series. However,
> I pass rm -f ./114*, I get to many arguments as an error. What I
> want to delete is all files from before June.
The definitive replacement of `rm -f ./114*` with many arguments is
find . -name "114*" | xargs rm -f
with the caveat that it will descend into subdirectories.
If you care... The reason your command didn't work is that your shell
does the wildcard expansion before passing the arguments to rm.
However there is a limit to the size of all arguments passed to a
This is where xargs comes in handy. It will read the standard input
and execute the utility as many times as necessary with the maximum
number of arguments.
find is an extremely powerful utility. I suggest reading the man
page for find. It has many other uses.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2593 bytes
Desc: not available
Url : http://lists.nycbug.org/pipermail/talk/attachments/20060621/5cc5821e/attachment.bin
More information about the talk