Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Grep multiple patterns

Shell Programming and Scripting


Tags
grep multiple patterns

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 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 Unix and Linux 09-23-2005
indo1144's Unix or Linux Image
indo1144 indo1144 is offline
Registered User
 
Join Date: Jun 2002
Last Activity: 1 July 2015, 10:18 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 Unix and Linux 09-23-2005
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Why the UUOC ?

Wouldnt this work ?


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

vino
Sponsored Links
    #5  
Old Unix and Linux 09-25-2005
Just Ice's Unix or Linux Image
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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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:34 AM.