Saturday, February 11, 2017

grep on Windows 7 Invalid Argument




I am using grep from Gnuwin32 on Windows.



Doing:



grep -r INSERT *.sql


Yields:



grep: *.sql: Invalid argument



Any idea why?


Answer



According to the Grep manual:



-r with grep is recursive directory searching, so to use it you specify the starting directory, not a file mask.



e.g.:




grep -r INSERT . would look at all files for INSERT, starting at the current directory (.) and recursively working its way through the sub-folders.



To specify recursive folder checking and specify a file wildcard to limit searches, you can use the --include option:



grep -r --include "*.sql" INSERT .



Similar question/info over on StackOverflow: How do I grep recursively?


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...