grep command

Hi...

I have this script below :

$ORACLE_HOME/bin/sqlplus "/as sysdba" @/ek_ora/script/rman_error.sh > rman_error.txt

more rman_error.txt | grep -i "FAILED" >> /ek_ora/script/rman_error.tmp
if [ ! -s "/ek_ora/script/rman_error.tmp" ]
then
echo "No error found."
else
echo "Sending mail."
mailx -r oraadm@jupp.gov.my -c encass@nc.com.my -s "RMAN Error" technical@precisionportal.com.my\
< /ek_ora/script/rman_error.tmp
fi

==================================

Based on that script it will grep "FAILED" only. If identified, the script will email to me...if else, it wont send any email..

My question is, in the file rman_error.txt, sometimes there will be another value i need to grep, i need to grep ERRORS and WARNING as well, so how to do this ???

won't this work?
more rman_error.txt | grep -i "FAILED" | grep -i "WARNING"

My test script:
text file contains:
i am a Warning
here is a blank
here is a Fail
failed everything
pls warn bla bla
Its Failed...

from the shell, I did this and got the result:
cat test | grep -i warn | grep -i fail test
here is a Fail
failed everything
Its Failed...

Oh...yes... "warn" IS NOT captured. Let me try.

How abt this:
bash-2.05$ cat test | egrep -i -v warn,fail
i am a Warning
here is a blank
here is a Fail
failed everything
pls warn bla bla
Its Failed...

Hi Incredible
Thanks for take such an inisiatif

But still i cant grep with both string, it can show only one string. I try this :

This is the content of rman_error.txt :
------------------------------------

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Jul 23 14:16:48 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

START_TIME END_TIME STATUS
---------- --------- -----------------------
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
24-JUL-08 24-JUL-08 FAILED
24-JUL-08 24-JUL-08 COMPLETED WITH WARNING
23-JUL-08 23-JUL-08 COMPLETED WITH WARNING
START_TIME END_TIME STATUS
---------- --------- -----------------------
23-JUL-08 23-JUL-08 COMPLETED

12 rows selected.

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

This is the command i use :

bash-3.00$ more rman_error.txt | egrep -i 'COMPLETED'

23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
23-JUL-08 23-JUL-08 COMPLETED
24-JUL-08 24-JUL-08 COMPLETED WITH WARNING
23-JUL-08 23-JUL-08 COMPLETED WITH WARNING
23-JUL-08 23-JUL-08 COMPLETED

When i use this command, it doesnt return any value :

bash-3.00$ more rman_error.txt | egrep -i 'COMPLETED' | egrep -i 'FAILED'
bash-3.00$

bash-3.00$ cat rman_error.txt | egrep -i 'COMPLETED' | egrep -i 'FAILED'
bash-3.00$

bash-3.00$ more rman_error.txt | grep -i "COMPLETED" | grep -i "FAILED"
bash-3.00$

Hmmm....i'm using Solaris 10 by the way

SOLVED....

I'm using this command :

more rman_error.txt | egrep "FAILED|COMPLETED WITH ERRORS|COMPLETED WITH WARNING"

:b:

Great man! cannot use grep instead of egrep is it? Anyway learnt to use "string|string|string".. remembered :stuck_out_tongue: