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! Click here to start participating now! Also, 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.




Response Number 1
Name: pnbalaji
Date: February 4, 2009 at 11:47:19 Pacific
+1
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.


Reply to Message Icon

Related Posts

See More


installation of unix on V... replace cc numbers



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Google Ads



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