On 27/2/2011, at 6:30am, Alan McKinnon wrote: > On Sunday 27 February 2011 03:46:48 Stroller wrote: >> On 26/2/2011, at 5:33pm, Grant wrote: >>> >>> find /my/folder -type f -name '*foo*.txt' >> > > He didn't quote the search string and neither did the grandparent. Find will > do what he's asking and it's most unlikely that's what he wants. > > Grant, you have > > find /my/folder -name foo*.txt > > but you want > > find /my/folder -name 'foo*.txt'
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. So as long as he doesn't have a foo*.txt in his current working directory then either command should work fine. $ ls my/folder/ foo.txt $ ls foo.txt foo.txt $ rm foo.txt $ find my/folder -name foo*.txt my/folder/foo.txt $ ls fo*.txt ls: cannot access fo*.txt: No such file or directory $ find my/folder -name fo*.txt my/folder/foo.txt $ find my/folder -name *fo*.txt my/folder/foo.txt $ find my/folder -name '*fo*.txt' my/folder/foo.txt $ 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. Stroller.