Why doesn't 'find' show this file?

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

# find | grep error
./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html
./error_log
./includes/classes/error_log

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

# find . -name error*
./error_log
./includes/classes/error_log

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

Asked By: dotancohen

||

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.

Answered By: Dennis Kaarsemaker
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.