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

Using find with grep, one can locate files that match a pattern:

# find | grep error

However, using find alone the first file is not found:

# find . -name error*

Why doesn't find locate the errors.html file when not used with grep? How is find used to show this file as well?

share|improve this question
up vote 41 down vote accepted

You need to quote your argument error* because the shell expands it. So what you're actually running now is find -name error_log, because that's what the shell can expand it to (there's a file named error_log in your current directory).

find . -name 'error*'

Is the correct invocation for your use case.

share|improve this answer
Thank you Dennis! I knew that it had to be simple! – dotancohen Nov 11 '12 at 10:24
an altenative writing is find -name error\* - one key less to press ;) this has the same effect, the * gets passed as an literate asterisk to the find command and is not expanded by your shell – zhenech Nov 11 '12 at 11:14
When having trouble with the shell (how it interprets your command-line and passes all arguments and parameters to the actual command), re-run the command prepending it with the echo command. So, if you'd run echo find . -name error* it would have outputted find . -name error_log – Carlos Campderrós Nov 12 '12 at 10:01

Your Answer


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.