Grep multiple patterns | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

Grep multiple patterns

Shell Programming and Scripting


Tags
grep multiple patterns

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-23-2005
malaymaru malaymaru is offline
Registered User
 
Join Date: May 2005
Last Activity: 28 April 2008, 7:23 AM EDT
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Grep multiple patterns

Hi,

Can we grep multiple patterns in UNIX.
for example:
cat /x/y/oratab | grep -i "pattern1|pattern2" .... etc

I require the syntax for multiple patterns. | is not working as I explained in example.

Malay
Sponsored Links
    #2  
Old 09-23-2005
shihabvk shihabvk is offline
Registered User
 
Join Date: May 2005
Last Activity: 14 July 2009, 8:56 AM EDT
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
try !!!!
cat /x/y/oratab | egrep -i "pattern1|pattern2"

Shihab
Sponsored Links
    #3  
Old 09-23-2005
indo1144's Avatar
indo1144 indo1144 is offline
Registered User
 
Join Date: Jun 2002
Last Activity: 9 October 2014, 7:56 AM EDT
Location: Netherlands
Posts: 54
Thanks: 0
Thanked 2 Times in 2 Posts
Depending on your version of grep, this might also work:

cat /x/y/oratab | grep -i -e pattern1 -e pattern2
    #4  
Old 09-23-2005
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 Posts
Why the UUOC ?

Wouldnt this work ?


Code:
grep -i -e pattern1 -e pattern2 /x/y/oratab

vino
Sponsored Links
    #5  
Old 09-25-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
 
Join Date: Mar 2005
Last Activity: 20 September 2013, 10:59 AM EDT
Location: Philadelphia metro
Posts: 958
Thanks: 3
Thanked 67 Times in 60 Posts
or ...


Code:
egrep -i "str1|str2" /your/file

The Following User Says Thank You to Just Ice For This Useful Post:
MellyMe (10-07-2011)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep for multiple patterns tene Shell Programming and Scripting 10 12-01-2009 02:26 PM
grep multiple patterns + the whole word only meheretoknow Shell Programming and Scripting 2 12-11-2008 06:26 AM
To grep multiple patterns with space in between them...... prashantshukla Shell Programming and Scripting 5 09-10-2008 01:25 PM
Grep for Multiple patterns WillImm123 Shell Programming and Scripting 7 03-01-2006 03:23 PM
grep for multiple patterns tselvanin UNIX for Dummies Questions & Answers 1 11-12-2003 06:43 PM



All times are GMT -4. The time now is 08:46 AM.