On Wed, Mar 07, 2007 at 08:01:10AM -0800, Randall R Schulz wrote: > On Wednesday 07 March 2007 03:12, Philippe Andersson wrote: > > Gordon Ross wrote: > > ... > > > > $ find DHbox* -name "*.dat" -o -name "*.pro" -exec rm -f {} \; > > > > would do. Omit the final "-exec..." to first check that it only > > catches those files you want to get rid of. > > If there are very many such files, execing a separate rm for each will > be slow. The "|xargs rm" approach only invokes as many rm instances as > it takes to handle the number of arguments present. It also frees you > from the funky find -exec syntax, which many find confusing.
If you pipe into xargs, you probably want to also use find -print0/xargs -0 to protect against filenames containing spaces and other oddities, e.g.: $ find DHbox* -name "*.dat" -o -name "*.pro" -print0 | xargs -0 rm -print0 emits the list of files as a set of null terminated strings, and -0 tells xargs to expect that format and compensate accordingly. As usual, see the find(1) and xargs(1) man pages for more details. -- Steve Beattie SUSE Labs, Novell Inc. <[EMAIL PROTECTED]> http://NxNW.org/~steve/
pgpunwip4I0NZ.pgp
Description: PGP signature