1 |
>>> Alright, find is tricky. Is this the right spot for -delete? |
2 |
>>> |
3 |
>>> /usr/bin/find /home/user -type f -name "*-`/bin/date -d 'yesterday' |
4 |
>>> +\%Y\%m\%d`*.jpg" - delete |
5 |
>> |
6 |
>> Yes, but if you don't want irreversible mistakes, move the files instead. |
7 |
>> |
8 |
>> find /home/user -type f -name blah -exec mv -t ~/.Trashcan "{}" + |
9 |
>> |
10 |
>> |
11 |
> |
12 |
> In all these commands it would always be a good idea to deactivate |
13 |
> parameter parsing just in front of the place where the file names are |
14 |
> inserted. |
15 |
> |
16 |
> find ... -print0 | xargs -0 mv -t ~/.Trashcan -- |
17 |
> or |
18 |
> find ... -exec mv -t ~/.Trashcan -- "{}" + |
19 |
> |
20 |
> The double dash will prevent mv from interpreting weird file names like |
21 |
> "-h" as parameters. Just about every standard GNU tool supports this. |
22 |
|
23 |
Does that apply to a command like this: |
24 |
|
25 |
/usr/bin/find /home/user -type f -name "*-`/bin/date -d 'yesterday' |
26 |
+\%Y\%m\%d`*.jpg" -delete |
27 |
|
28 |
Maybe it should be changed to this: |
29 |
|
30 |
/usr/bin/find /home/user -type f -name -- "*-`/bin/date -d 'yesterday' |
31 |
+\%Y\%m\%d`*.jpg" -delete |
32 |
|
33 |
- Grant |