1832267 Members
3411 Online
110041 Solutions
New Discussion

Need for shell script

 
Hunki
Super Advisor

Need for shell script

I have this build log which from which I need to check for failed, warning, cannot...
Is there a way it can be run through a shell script ( like a case - esac statement with one each for failed, warning , cannot )
egrep -i failed bldlogtest_cur.022306
egrep -i warning bldlogtest_cur.022306
egrep -i cannot bldlogtest_cur.022306
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Need for shell script

Hi:

You can specify multiple tokens in one command as:

# grep -i -e failed -e warning -e cannot bidlogtest_cur.022306

Regards!

...JRF...
Bill Thorsteinson
Honored Contributor

Re: Need for shell script

Consider using egrep -v with
patterns in a file to remove expecte chatter.

Or us egrep -v with multiple patterns
egrep -e failed -e warning -e cannot

The output will be a list of the occurences
of the three words.

You could play with IFS to read this line
by line and use case to match each occurance.

I would consider perl for this.

Also look at the 'logcheck' script and see
if it could do what you want.
Hunki
Super Advisor

Re: Need for shell script

I did :
egrep -e failed -e warning -e cannot bldlogprod.032806

but it gave me output of only cannot
James R. Ferguson
Acclaimed Contributor

Re: Need for shell script

Hi (again):

In you original post you explicitly showed a case-insensitve match (-i). Thus, I suggested:

# grep -i -e failed -e warning -e cannot bidlogtest_cur.022306

Regards!

...JRF...
Hunki
Super Advisor

Re: Need for shell script

egrep -i -e failed -e warning -e cannot bldlogprod.032806

giving output of only cannot ...
Hunki
Super Advisor

Re: Need for shell script

grep does not have the -e :-(
Sandman!
Honored Contributor

Re: Need for shell script

The egrep usage for an OR construct should be...

# egrep -i "failed|warning|cannot" bldlogtest_cur.022306

...as you're looking for failed OR warning OR cannot lines.

cheers!
Hunki
Super Advisor

Re: Need for shell script

Thanks Sandman it worked,thanks all for replying, also it worked using :

egrep -i -f list bldlogprod.032806

with list containing the following content :

failed
warining
cannot

Sandman!
Honored Contributor

Re: Need for shell script

Hello,

The only reason why egrep finds "cannot" but not "failed" or "warning" lines is because there aren't any. The command's good, but the file that needs parsing doesn't have all the patterns to be matched.

>> egrep -i -e failed -e warning -e cannot bldlogprod.032806
>> giving output of only cannot

cheers!