Simple recursive grep

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Simple recursive grep

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Simple recursive grep

Post 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 .
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

egrep -r TEST_ME
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: Simple recursive grep

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ;)
Post Reply