1846732 Members
4793 Online
110256 Solutions
New Discussion

shell scripting help

 
Archana1
Frequent Advisor

shell scripting help

Hi,

Iam mid of Shell scripting and Iam looking for command which should NOT capture
"WARN [00000003]" entry from below given log.

2010-04-02T01:57:18,814 WARN [00000003] sas - SAS Object Spawner Daemon III has completed initi
2010-04-02T01:57:18,815 WARN [00000004] sas - SAH021999I Server SAS Object Spawner Daemon III (
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: shell scripting help

Hi:

# grep -v "WARN [00000003]" file

...will output everything from 'file' that does *not* match.

You might use this in cases like this:

# grep "WARN" file|grep -v "WARN [00000003]"

...which would look for all instances of "WARN" in 'file', but skip those matching "WARN [00000003]".

Regards!

...JRF...
Regards!

...JRF...
Kapil Jha
Honored Contributor

Re: shell scripting help

you can use
egrep -v "WARN [00000003]|second_word|3rd_word"

although its lil heavy but quite handy.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Dennis Handly
Acclaimed Contributor

Re: shell scripting help

>Kapil: egrep -v "WARN [00000003]|second_word|3rd_word"
>although it's lil heavy but quite handy.

Rather than use the egrep hammer, it may be easier to use multiple -e options:
grep -v -e "WARN [00000003]" -e second_word -e 3rd_word

Also since "[" is special to grep, it needs to be quoted or use fgrep instead:
grep -v -e 'WARN \[00000003]'
Steven Schweda
Honored Contributor

Re: shell scripting help

It might help if you specified exactly what
you do wish to extract from the file, as well
as what you wish not to extract from it.