grep does not recurse

I'm not sure why the recurse flag doesn't work, but here's a workaround that works for me. The -r flag takes an argument: the directory to search. To search the current directory, give it the argument .. For example

grep regexp-to-find -r . --include=*.c

Edit

This is actually the expected behavior of grep, and has nothing to do with running it on Windows. The -r flag takes a directory argument. Check out HairOfTheDog's answer for why.


Grep's -r option (which is the same as the -R, --recursive, -d recurse and --directories=recurse options) takes a directory name (or pattern) as its argument. The command you are trying to execute should be interpreted as "Starting in the current working directory recurse all directories matching the pattern *.c. In each of those directories search all files for the string iflag."

Tags:

Grep