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