Searching for specific files then delete them

Dieter Schicker dieter.schicker at uni-graz.at
Tue Aug 29 20:50:47 UTC 2006


On Tue, 2006-08-29 at 22:30 +0200, Dennis Kaarsemaker wrote:
> On di, 2006-08-29 at 14:24 +0100, Tony Arnold wrote:
> > > find . -name *~ | xargs rm
> > 
> > or
> > 
> > find . -name *~ -exec rm {} \;
> > 
> > The rm command gets executed for each file found and the {} is
> > substituted with the file name. The \; is necessary syntax to
> > terminate
> > the -exec option. 
> 
> That's not an 'or', that's the correct way.
> 
> The suggestion from Dieter will fail on filenames containing e.g.
> spaces.
> 
> find . -name *~ -print0 | xargs -0 rm 
> 
> works better, but find's -exec is really much better (if you quote the
> {} ;))
> 

Ok, thanks. I learned something again. 

BTW: Filenames with spaces are forbidden in my network. 
Which unfortunately doesn't mean that people use them heavily ... ;-)

Dieter




More information about the ubuntu-users mailing list