I did try the --include way but in Cygwin it didn't work for some reason. Neither does
find "." -name "*.log" -exec grep -nH "my pattern" {} \; or find "." -name "*.log" | grep -nH "my pattern" So struggling about on Cygwin at the moment. Sean Daley-2 wrote: > > On Tue, Aug 7, 2012 at 11:08 AM, AngusC <> wrote: >> >> If I use the command: >> >> grep -nH -r "my pattern" *.* >> >> I get results back as expected >> >> But if the file pattern is like this: >> >> grep -nH -r "my pattern" *.log >> >> I get no results back (Even though I have a ton of files with this >> pattern >> with .log file extension). >> >> Am I doing something wrong? >> -- > The first one works because *.* will match everything your current > directory, > including sub-directories and it will recurse through each of them. The > second example will first match anything in your current directory with a > .log > extension and try to grep it (if it's a file) or recurse through it if > it's a directory. > > What I believe you want to do (at least works on Linux) is > grep -nH -r "my pattern" --include "*.log" . > > Sean > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > > > -- View this message in context: http://old.nabble.com/problem-using-recursive-grep-%28-r-option%29-tp34266659p34270643.html Sent from the Cygwin list mailing list archive at Nabble.com. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple