1753501 Members
4927 Online
108794 Solutions
New Discussion юеВ

Grep Help

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Grep Help

Hello,

I am wondering if there is a command/script to grep words from numerous configuration files in 30+ subdirectries.

I use:

grep "test.com" /disk1/oracle/* |more

it only search a file right under /disk1/oracle. I need 30 subdir under it that are all searched.

Any comment are very appreciated.

Steven
Steve
4 REPLIES 4
Pete Randall
Outstanding Contributor
Solution

Re: Grep Help

Try the find command:

find /desk1/oracle -exec grep -l "test.com" {} \;


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: Grep Help

Hi Steven:

The following will 'grep' within all subdirectories; be resource-conservative; *and* show you the filename associated with any matches:

# find /disk1/oracle -xdev -type f | xargs grep -i "test.com"

Regards!

...JRF...
Shahul
Esteemed Contributor

Re: Grep Help

Hi,

This will do,

for I in `find /dir/subdir/. -print`
do
grep "string" $I
done

Regards
Shahul
H.Merijn Brand (procura
Honored Contributor

Re: Grep Help

I'd use GNU grep

# grep -r -w test.com /disk1/oracle

-r grep recursively
-w grep word anchored

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn