Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grep question 1

Status
Not open for further replies.

clegg

Programmer
Jan 25, 2001
98
GB
I want to search for a string plus either of 2 more strings but I don't know how to form the syntax

EG cat afile | grep 'text1' AND (text2 OR text3) > results

Any help would be appreciated

Clegg
 
Try something like this:
grep 'text1' afile | grep -E 'text2|text3' > results
If your grep version don't like the -E option, try this:
grep 'text1' afile | egrep 'text2|text3' > results

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top