The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with grep on search string in a txt file over multiple files m00 UNIX for Dummies Questions & Answers 2 05-18-2008 11:21 AM
Multiple search in multiple files maxvirrozeito Shell Programming and Scripting 2 12-13-2007 09:32 AM
Problem to search multiple strings sudhish Shell Programming and Scripting 2 10-25-2007 11:00 AM
Multiple search and replace tungaw2004 UNIX for Dummies Questions & Answers 1 03-21-2007 08:03 PM
Search for files in multiple directories ravikirankethe UNIX for Dummies Questions & Answers 7 10-29-2006 01:29 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-03-2006
Registered User
 

Join Date: Jan 2006
Posts: 71
Stumble this Post!
multiple search with grep

is it possible to execute multiple search with grep???

grep criteria1 criteria2 file


something like this...

I know other way:

grep pattern1 file-name1 > results-file
grep pattern2 file-name1 >> results-file
cat results-file

but can it be done with one grep????
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-03-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 371
Stumble this Post!
grep -E "criteria1|criteria2" file
Reply With Quote
  #3 (permalink)  
Old 04-03-2006
Registered User
 

Join Date: Jan 2006
Posts: 71
Stumble this Post!
thanks I will try
Reply With Quote
  #4 (permalink)  
Old 04-03-2006
Registered User
 

Join Date: Jan 2006
Posts: 59
Stumble this Post!
Or there is:

grep -e "pattern1" -e "pattern2" file
Reply With Quote
  #5 (permalink)  
Old 04-04-2006
Registered User
 

Join Date: Sep 2005
Location: Chennai
Posts: 80
Stumble this Post!
You can try grep -f too....u can generalise that way, for multiple patterns
Reply With Quote
  #6 (permalink)  
Old 04-04-2006
Registered User
 

Join Date: Dec 2005
Posts: 25
Stumble this Post!
egrep "pattern1|pattern2|.....|patternn" filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0