Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

marked as duplicate by Gilles, 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.

up vote 2 down vote accepted

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).

share|improve this answer

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

You always have to use some quotes.

share|improve this answer

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