This question already has an answer here:

When I have a nested directory find . -name "*.py" -print command gives me all the python scripts beneath current directory. However, find . -name *.py -print returns only the python scrips in current directory.

Is this expected behavior? What makes this difference? I use Mac OS X 10.7.

marked as duplicate by Gilles 'SO- stop being evil', slm, jasonwryan, Renan, Anthon Aug 14 '13 at 4:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


It's probably not the same command. You could put echo in front to check.

$ echo find . -name "*.py" -print
find . -name *.py -print

$ echo find . -name *.py -print
find . -name foobar.py barfoo.py -print

Without quotes, the shell expanded *.py, so find gets different arguments, which yields different results.

You should always quote * when you want a command to see * literally. Otherwise the behaviour will be erratic (the command works as long as there are no *.py files for the shell to expand to).


Because the shell expands the wildcard when you don't protect the pattern.

You always have to use some quotes.

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