bug-grep
[Top][All Lists]
Advanced

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

Re: Grep --include does not work


From: Bob Proulx
Subject: Re: Grep --include does not work
Date: Sat, 2 Jun 2007 11:01:22 -0600
User-agent: Mutt/1.5.9i

Andreas Schwab wrote:
> LeonM <address@hidden> writes:
> > For example if I have directories in Windows with binary and text file
> > and if I do this:
> >  grep -R --include=*.txt "include" *
> >
> > it will grep even the binary files as well. Clearly this is wrong.
> 
> This is not a bug.  The files mentioned on the command line will always
> be considered, independent of --include.  The latter is only consulted
> for files encountered during the recursive walk.

Instead of '*' use '.' when using the 'grep --recursive' feature.
For example:

  grep -R --include="*.txt" "include" .

Then the --include directive will operate as you expect.

Also all shell metacharacters should be quoted to prevent accidental
file glob expansion regardless of it being unlikely when using the '='
parameter passing form.

Bob




reply via email to

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