Super User is a question and answer site for computer enthusiasts and power users. 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

I was using

find -iname *prib*

and getting only one result "./prib09jack.pdf" with

find -iname "*prib*" 

I get many more results that I was looking for such as


and many more, but why did it matter that the quotation marks were around "prib"?


share|improve this question
Did you launch the command from the same directory and got different answers? What was the whole find command structure you used as there are many options which affect the outcome. – dtlussier Aug 26 '10 at 16:27
I was in the same directory for each use changing only the quotations around the search string. – Vass Aug 26 '10 at 16:37
up vote 10 down vote accepted

If there is a file (or files) matching *prib* in the current directory when the find command is run, the shell will expand the wildcard to match the file name(s) first before handing the arguments to find, and result in a different command being run than the user expects.

For example,

$ ls foo*

$ find -iname foo*

$ find -iname "foo*"

In short, Quotes delay wildcard interpretation for the find command to perform. Lack of quotes expands immediately.

share|improve this answer
wow, that was deep. I can't say that I completely understood it. So should I always be using the quotes in similar situations? What you said sounded like if it encounters a string matching a form of the wildcard further searches follow this initial wildcard expansion. And that the quotes stop this from happening. (if Im not mistaken the man page says nothing to avoid such a mistake). – Vass Aug 26 '10 at 16:55
You'd find it explained in the bash man page, not the find man page, because quoting is handled by the shell. Basically (to repeat what kmarsh said), if you use *prib* without quotes, bash looks for files in the current directory with names matching that pattern and replaces *prib* with the names of the files before invoking find. If you use quotes, bash leaves the *prib* alone. – David Z Aug 26 '10 at 17:02
thanks a ton, I even understood that! – Vass Aug 26 '10 at 17:09
@Vass: You can use echo *prib* and such to see what bash does to the arguments before it passes them to the command. echo itself just prints it's arguments unchanged, so it's output tells you to what bash expanded the *prib*. – sth Aug 26 '10 at 17:37
@sth zaw. Thanks, alot. that was eye opening. Thanks alot for bothering to tell me this. Its like there is a whole other dimension to the command line that I was unaware of. – Vass Aug 26 '10 at 20:38

The issue is that your shell is expanding the wildcard *'s before handing them to find. You want find to get them, so you need to escape them. The quotes do that, or you could do

find -iname \*iprib\*

and it would work as well. The key thing is, you want the wildcards to make it to find uninterpreted by anything else along the way (like your shell).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .