1 |
On Saturday 22 May 2010 08:25:55 Neil Bothwick wrote: |
2 |
> On Sat, 22 May 2010 12:35:10 +0100, David W Noon wrote: |
3 |
> > >find -name *.ext -exe rm "{}" + |
4 |
> > |
5 |
> > Or simpler still: |
6 |
> > |
7 |
> > find -name *.ext -delete |
8 |
> |
9 |
> Neat - I hadn't noticed that option. |
10 |
> |
11 |
> Anyone for find / -delete ? |
12 |
|
13 |
If you use the -delete switch, just be careful. From the man page: |
14 |
|
15 |
<QUOTE> |
16 |
Warnings: Don't forget that the find command line is evaluated as an |
17 |
expression, so putting -delete first will make find try to delete |
18 |
everything below the starting points you specified. |
19 |
</QUOTE> |
20 |
|
21 |
That means that the command |
22 |
|
23 |
find -name *.tmp -delete |
24 |
|
25 |
will delete all your temp files while |
26 |
|
27 |
find -delete -name *.tmp |
28 |
|
29 |
will delete everything below your current directory. If you're in the root |
30 |
directory, it's equivalent to running your suggested command above. I just |
31 |
found this out the hard way, although luckily I wasn't in the root directory |
32 |
when I ran the command and so didn't trash my system. I did lose the changes |
33 |
I'd made to the project I was working on but fortunately had a backup of the |
34 |
original files. |
35 |
|
36 |
-- |
37 |
"If you give me six lines written by the most honest man, I will find something |
38 |
in them to hang him." - Cardinal Richelieu |