[CS3194-list] "find" command arguments -- quote or not?

Berna Massingill bmassing at cs.trinity.edu
Thu Feb 12 13:01:17 CST 2004


To clear up a minor detail from Monday's class (and try out this
mailing list):

You may remember that Monday in class I was surprised to find that
apparently it wasn't necessary after all to put arguments to "find"
containing wildcards in quotation marks, since I got the same results
with

    find Classes -name *.java

as with 

    find Classes -name "*.java"

I had always read that you needed the quotation marks to keep the
shell from expanding the wildcard, so I was surprised that the first
version of the command worked.  The explanation is that if the shell is
unable to expand a wildcard, it just leaves it unexpanded, and since
there were no files that matched the "*.java" in the directory where
I executed the above commands, the "*.java" was passed unexpanded to
"find".

To see the effect of this, try a command such as "echo *.c" first in
a directory that contains at least one file that matches the wildcard
and then in a directory that doesn't.

Well, *I* was glad to clear that up.

-- blm


More information about the CS3190unix-list mailing list