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
grep for pattern aemunathan Shell Programming and Scripting 12 05-08-2008 11:58 PM
How to grep this pattern?? askumarece Shell Programming and Scripting 13 02-20-2008 04:03 AM
help with grep the pattern bluemoon1 Shell Programming and Scripting 2 09-20-2007 08:27 AM
unable to grep the following pattern suri Shell Programming and Scripting 2 03-07-2007 12:03 AM
search pattern by grep vijaysabari Shell Programming and Scripting 3 06-23-2004 12:03 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-13-2005
Registered User
 

Join Date: Aug 2003
Location: Ireland
Posts: 269
grep for more than one pattern

I want to grep for more than one pattern in a file...

ie.. grep for root and nobody in /etc/passwd file and then count the occurances..

Ideally I would want to do this but I know it doesnt work
grep -c root nobody /etc/passwd


Any ideas?
Reply With Quote
Forum Sponsor
  #2  
Old 12-13-2005
Registered User
 

Join Date: Sep 2005
Location: india
Posts: 78
look at -e option with grep
Reply With Quote
  #3  
Old 12-13-2005
Registered User
 

Join Date: Aug 2003
Location: Ireland
Posts: 269
I did - but have not been able to figure out how to use it - can you help?
Give an example etc?
Reply With Quote
  #4  
Old 12-13-2005
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
grep -ce "root" -e "nobody" /etc/passwd

bakunin
Reply With Quote
  #5  
Old 12-13-2005
Registered User
 

Join Date: Aug 2003
Location: Ireland
Posts: 269
Excellent - thank you very much!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:58 AM.


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

Content Relevant URLs by vBSEO 3.2.0