If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > grep mutiple erpressions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-04, 09:28
estumator estumator is offline
Registered User
 
Join Date: Feb 2004
Posts: 6
grep mutiple erpressions

I want to use grep to ckeck file errors, in which case ,I used
number_of_errors=$(grep -v -c (pattens) file)
there r 2 problems , firstly , I want to use mutiple pattens and match any one of them (in this case if non of them is matched, since -v is used as an option).
2ndly, I want to assign the returned number to a variable, and my expression is incorrect.....
Any help would be appreciated.^_^
thanks for ur attention.
Reply With Quote
  #2 (permalink)  
Old 02-23-04, 09:42
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
use 'egrep' or 'grep -E' :

Code:
#Count lines with ERROR or WARNING
count1=$(egrep -c 'ERROR|WARNING) file)

#Count lines without ERROR and WARNING
count2=$(egrep -v -c 'ERROR|WARNING' file)
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-23-04, 09:57
estumator estumator is offline
Registered User
 
Join Date: Feb 2004
Posts: 6
It works ,many thanks.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On