Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want show all the files that have a .bak extension.

kaykav@ubu2:~/Documents$ ls
cdIndex1-60  met.bak  tem.bak

I type the cmd : $ find . -name *.bak

I'm in the correct Directory for this. I get the following message:

find: paths must precede expression: tem.bak

What does that mean? Man pages are no help.

share|improve this question
add comment

1 Answer 1

Try putting it in quotes:

find . -name '*.bak'

When you simply use find . -name *.bak in that directory shell expands it to find . -name tem.bak met.bak (i.e. interprets * as the wildcard)

share|improve this answer
    
thank you for your reply. I'm not sure I comprehend the answer but it works. I thought *.bak means 'all' results that have a .bak ending. –  kaykav Jul 9 '12 at 0:44
1  
@kaykav When you run find . -name *.bak, the third command-line argument, *.bak, is expanded by the shell before it is passed to find. Shell expansion will convert it to a space-delimited list of all the filenames in the current directory that match it, i.e., all the files whose names consist of zero or more characters (*) followed by .bak. When you enclose *.bak in quotes, that escapes the * wildcard, so the expression is passed unexpanded. You could alternatively use find . -name \*.bak. –  Eliah Kagan Jul 9 '12 at 3:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.