bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep FILE spec


From: Paul Jarc
Subject: Re: grep FILE spec
Date: Wed, 27 Feb 2002 16:12:42 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/20.7 (i386-redhat-linux-gnu)

Edward Dunkle <address@hidden> wrote:
>  grep -n -r -e ProductType *.java
> gives grep: *.java: No such file or directorywhen the current directory
> holds no .java file, but they DO exist farther down the file structure

Wildcards are expanded by the shell before grep sees them.  The shell
doesn't know what grep's -r option means, so "*" becomes a list of
files in the current directory.  You could quote the "*" to prevent
the shell from substituting it, but that wouldn't help because grep
would look for a file or directory called "*".  grep doesn't know how
to expand wildcards; that's the shell's job.

> So how do you get it to look through all directories (recurse) but only
> match on certain files (*.java)?

man find
man xargs
find . -name '*.java' -print0 | xargs -0 grep -n -e ProductType /dev/null


paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]