Re: grep and recursion

Keith MARSHALL <[email protected]>
Newsgroups gmane.comp.windows.gnu.user
Message-ID <OFACE0CF1F.7C5108B4-ON8025742F.0036FE88-8025742F.0039CE95@total.com>



Bonno Bloksma wrote:
> I've read the previous posts in the group and I thought I had the
> correct syntax but.... I must be doing something wrong.
>
> ----------<quote>-------------------------------
> D:\temp\MANSYS>"c:\Program
> Files\GnuWin32\bin\grep.exe" -ir --include="*.rec" "version" .

That looks absolutely fine to me; indeed that syntax works just as
you and I both seem to expect, on my GNU/Linux box, (where I also have
grep-2.5.1).

Just a wild guess, (I can't verify it, because I don't use *any* tools
from cmd.exe, preferring the MSYS bash shell, and I use MSYS grep, not
the GnuWin32 variant, which I don't have), but since cmd.exe does not
perform the quote reduction the way a *nix shell would, grep has to do
that itself; it appears that it does so, for the RE pattern argument,
but maybe not for the globbed include pattern.  What happens, if you
omit the quotes in `--include=*.rec', or wrap the *entire* argument
in quotes, as `"--include=*.rec"'?

In any case, this looks like a bug in GnuWin32 grep.

Regards,
Keith.

FWIW, this doesn't work with MSYS grep-2.4.2, since that doesn't
support the `--include' option.  Instead, I would use:

  find . -iname "*.rec" -exec grep -iH "version" {} +

(noting that this is a *nix compatible `find', *not* Microsoft's
 incompatible tool, of the same name).

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.