[Gllug] Excluding matches with grep

Jack Bertram jack at jbertram.net
Sun Jan 25 18:42:21 UTC 2004


* Dylan <dylan at dylan.me.uk> [040125 18:35]:
> Hi all,
> 
> I'm trying to filter some entries from a logfile to a text file. 
> Specifically, I want all firewall entries, except those which I can 
> already explain. For example - I don't want martian packets. So, 
> issuing:
> 
> cat /var/log/gateway.messages | grep SuSE-FW > fw.txt
> 
> gets all the firewall messages, then I can re-grep to extract particular 
> things by other patterns, but ideally I'd like to be able to do:
> 
> cat /var/log/gateway.messages | grep {reg-exp to match all lines with 
> SuSE-FW except (those with martian OR SPT=53 OR ...)} > fw.txt
> 
> Is this possible with grep? 

cat /var/log/gateway.messages | grep 'SuSE-FW' | grep -Ev '(martian)|(SPT=53)' > fw.txt

?

jack
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list