[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: regular expressions and grep



I think you can use | as or, so in this case it would be:

egrep -v 'named|smtpd' /var/adm/daemon.log


I'm using egrep because I want to search for regular expressions by
default, I'm not sure if it is necessary.  Also, don't forget to
quote your expression so that it's not treated by the shell as a pipe.

  Michael


 >Hi,
 >
 >I just can't seem to get the hang of regular expressions.  I am trying to use
 >grep to look at relevant lines in my system log, for example I can do this:
 >
 >>grep -v named /var/adm/daemon.log
 >
 >This shows all but the lines containing the word "named" (because my named
 >daemon shows a lot of garbage on boot up).  But there are several lines I 
 >would like to leave out, like those containing the word "smtpd".  I have not 
 >been able to figure out how to combine the two strings so that grep -v  ignor
>es
 >both of them, I've had to resort to
 >
 >>grep -v named /var/adm/daemon.log | grep -v smtpd
 >
 >It seems silly to have to run grep a separate time for each string I wish 
 >to exclude, can someone tell me how to combine the strings in the manner that
 >I desire?
 >
 >Thank you kindly,
 >Steve
 >



Reply to: