On Saturday 22 May 2010 08:25:55 Neil Bothwick wrote:
> On Sat, 22 May 2010 12:35:10 +0100, David W Noon wrote:
> > >find -name *.ext -exe rm "{}" +
> >
> > Or simpler still:
> >
> > find -name *.ext -delete
> 
> Neat - I hadn't noticed that option.
> 
> Anyone for find / -delete ?

If you use the -delete switch, just be careful.  From the man page:

<QUOTE>
Warnings: Don't forget that the find command line is evaluated as an 
expression, so putting -delete first will make find try to delete               
everything  below  the starting points you specified.  
</QUOTE>

That means that the command

find -name *.tmp -delete

will delete all your temp files while

find -delete -name *.tmp

will delete everything below your current directory.  If you're in the root 
directory, it's equivalent to running your suggested command above.  I just 
found this out the hard way, although luckily I wasn't in the root directory 
when I ran the command and so didn't trash my system.  I did lose the changes 
I'd made to the project I was working on but fortunately had a backup of the 
original files.
 
-- 
"If you give me six lines written by the most honest man, I will find something 
in them to hang him." - Cardinal Richelieu

Reply via email to