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.


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.