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: LeonM
Subject: Re: Grep --include does not work
Date: Fri, 8 Jun 2007 10:19:18 +1000

Thanks for the advice.

I have downloaded from
http://gnuwin32.sourceforge.net/packages/grep.htm

the version 2.5.1a and it works according to my reading of the
documentation. This
grep -R --include="*.txt" -P include *

works but the version 2.5.1a-1 fails to work correctly.

So it seems there is either an inconsistent interpretation of the
combination of switches or some programming logic rendering two
distinct behaviors. Either reason it is wrong right?

Bob

On 6/3/07, Bob Proulx <address@hidden> wrote:
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]