Computing.Net > Forums > Unix > using egrep to find multiple string

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

using egrep to find multiple string

Reply to Message Icon

Name: pnbalaji
Date: February 4, 2009 at 11:41:33 Pacific
OS: Windows XP SP3
CPU/Ram: 2GB RAM
Product: Dell / OPTIPLEX 755
Subcategory: General
Comment:

Hi,

I am trying to grep for the text matches of the following in our source codes.

ADD CBP
ADD CBV
WRITE CBP
WRITE CBV

The source components may end with *.bv or *.cpy or *.mac. I used find and egrep, but I am not able to search the above patterns. This is the command I used.

find /met /page \( -name '*.bv' -o -name '*.cpy' -o -name '*.mac' \) -exec egrep -il '(ADD|WRITE CB[PV])' {} \; 2>/dev/null

But the above command doesn't work unless I remove the CB[PV]. However I need to search for ADD CBP, ADD CBV, WRITE CBP and WRITE CBV.

Can some one help me how to acheive this?

Thanks,
Balaji.



Sponsored Link
Ads by Google

Response Number 1
Name: pnbalaji
Date: February 4, 2009 at 11:47:19 Pacific
Reply:

Never mind. I figured out the solution which is given below.

find /met/le \( -name '*.bv' -o -name '*.cpy' -o -name '*.mac' \) -exec egrep -i '(ADD|WRITE)(CBP|CBV)' {} \; 2>/dev/null
Thanks,

Balaji.


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: using egrep to find multiple string

finding a string from text www.computing.net/answers/unix/finding-a-string-from-text/7795.html

AWK command to find 2 values in a f www.computing.net/answers/unix/awk-command-to-find-2-values-in-a-f/5853.html

Need to find the string www.computing.net/answers/unix/need-to-find-the-string/7008.html