Problems with regular expressions

Hi ,

I am reading data from a log file.
The log file will be like this :
19:40:25 DEBUG : Failed xml-common.noarch 0-0.6.3-18 - u
19:40:25 ERROR : Batch failed
19:40:25 DEBUG : Batch exited with ERROR 104
19:40:25 ERROR : Batch exited with ERROR 105
19:40:25 DEBUG : Batch exited with ERROR 104
19:40:25 INFO : Batch exited with ERROR 105

I am reading this log file line by line.
I need to store the line which contain " *Batch exited with ERROR *" in a variable using regular expressions.
I am triyng something like this

cat Mytest.log | while read data
do
TEST=`echo $data | grep __________
echo $TEST
done

Can any one complete my grep command ? or suggest any other logic?

Regards
Subin

Try...

grep "Batch exited with ERROR" Mytest.log | while read line
do
  : something with $line
done

just grep for the pattern which you want,it can be like this--

cat Mytest.log | while read data
do
TEST=`echo $data | grep -i "Batch exited with ERROR "`
echo $TEST
done

Thanks for all ur reply.
But still i have still some problems in it :frowning:

19:40:25 DEBUG : Batch exited with ERROR 104
19:40:25 ERROR : Batch failed with ERROR 105
19:40:25 DEBUG : Batch stopped with ERROR 104

if the log file contain batch failed and batch stopped that also i need to store. means something like" *Batch*ERROR*".

Please any one can check this too

Regards,
Subin

Try...

egrep "Batch .* ERROR" Mytest.log

Thanks every one its working for me...