Page 1 of 1

Simple recursive grep

Posted: Fri Nov 03, 2006 7:04 pm
by alex.barylski
I need to search files for a static string 'TEST_ME' and I need it to be recusrsive...

I tried something like:
grep -e TEST_ME | find .*
But it hung on a text file???

Anyone?

Re: Simple recursive grep

Posted: Fri Nov 03, 2006 7:40 pm
by Chris Corbyn
Hockey wrote:I need to search files for a static string 'TEST_ME' and I need it to be recusrsive...

I tried something like:
grep -e TEST_ME | find .*
But it hung on a text file???

Anyone?
Hmmm, you've over complicated it ...

Code: Select all

grep -r TEST_ME .

Posted: Fri Nov 03, 2006 9:23 pm
by Jenk
egrep -r TEST_ME

Re: Simple recursive grep

Posted: Sat Nov 04, 2006 12:51 am
by jmut
Hockey wrote:I need to search files for a static string 'TEST_ME' and I need it to be recusrsive...
Execute within directory from which on you want to grep recursively.

Code: Select all

grep -nr 'TEST_ME' ./* | grep -v '\/\.svn'


#- n will give you line number where match in the file appears
#- i add it for case insensitive
#- r recursive
#- grep -v '\/\.svn'  if searching within subversion..to skip svn data.

Posted: Sat Nov 04, 2006 1:38 am
by volka
I tried something like:
grep -e TEST_ME | find .*
But it hung on a text file???
You want to perform a grep on all files in "this" directory and its subdirs?
find: -exec command ;

Code: Select all

find . -exec grep TEST_ME \{\} \;
But
Jenk wrote:egrep -r TEST_ME
is much simpler ;)