1 |
On 27/2/2011, at 6:30am, Alan McKinnon wrote: |
2 |
> On Sunday 27 February 2011 03:46:48 Stroller wrote: |
3 |
>> On 26/2/2011, at 5:33pm, Grant wrote: |
4 |
>>> |
5 |
>>> find /my/folder -type f -name '*foo*.txt' |
6 |
>> |
7 |
> |
8 |
> He didn't quote the search string and neither did the grandparent. Find will |
9 |
> do what he's asking and it's most unlikely that's what he wants. |
10 |
> |
11 |
> Grant, you have |
12 |
> |
13 |
> find /my/folder -name foo*.txt |
14 |
> |
15 |
> but you want |
16 |
> |
17 |
> find /my/folder -name 'foo*.txt' |
18 |
|
19 |
AIUI using `find /my/folder -name foo*.txt` (i.e. unquoted) the shell will pass the * to find if it can't expand it itself. |
20 |
|
21 |
So as long as he doesn't have a foo*.txt in his current working directory then either command should work fine. |
22 |
|
23 |
$ ls my/folder/ |
24 |
foo.txt |
25 |
$ ls foo.txt |
26 |
foo.txt |
27 |
$ rm foo.txt |
28 |
$ find my/folder -name foo*.txt |
29 |
my/folder/foo.txt |
30 |
$ ls fo*.txt |
31 |
ls: cannot access fo*.txt: No such file or directory |
32 |
$ find my/folder -name fo*.txt |
33 |
my/folder/foo.txt |
34 |
$ find my/folder -name *fo*.txt |
35 |
my/folder/foo.txt |
36 |
$ find my/folder -name '*fo*.txt' |
37 |
my/folder/foo.txt |
38 |
$ |
39 |
|
40 |
I maintain that if OP wanted useful advice he should have demonstrated stuff like the outputs of his find commands and of `ls foo*.txt` and `ls /my/folder/foo*.txt`. I am getting tired of giving this advice here. |
41 |
|
42 |
Stroller. |