2007/06/08

xargs rm

I have hundreds of thousands files in a directory starting with dfk*. When I try to remove them by "rm -f dfk*", the returned error prompt is "/bin/rm: Argument list too long". This says using wildcard syntax, there is an upper limit on the number of files that can be deleted by rm at one time.

My workaround solution is to perform "xargs rm" in the following way:

#find . -name 'dfk*' | xargs rm

The result is surprising. It works like a script to issue a command line to remove individual file one by one.

No comments: