Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 under the impression that the following command will search for, and list all Java files starting from the current directory and recursing down.

However, if I have a Java file in the root of my home directory, it lists that one, and then stops.

Is find supposed to stop at the first match, even with a wildcard? I guess I have a misconception about the usage. Thanks for any enlightenment.

find . -name *.java
share|improve this question
up vote 1 down vote accepted

The wildcard pattern *.java is expanded by your shell before it is passed to the find command. If you have a single file in the current directory, then the shell executes the command find . -name If you have two files and, the command find . -name is executed and find complains of a syntax error. If there is no matching file in the current directory, then the shell leaves the pattern unexpanded, so find . -name *.java is executed as you desire.

To tell the shell not to expand the pattern, so that it is always passed as-is to find, quote it:

find . -name '*.java'
find . -name "*.java"
find . -name \*.java
share|improve this answer
Splendid! Thanks. Shall "accept" in 3 minute. – EdgeCase Jan 20 '13 at 14:51

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.