![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regular Expressions | ramky79 | UNIX for Advanced & Expert Users | 3 | 05-21-2008 02:13 PM |
| regular expressions | melanie_pfefer | UNIX for Dummies Questions & Answers | 8 | 04-10-2008 01:24 AM |
| regular expressions | ragha81 | UNIX for Dummies Questions & Answers | 2 | 03-05-2007 04:24 PM |
| regular expressions in c++ | szzz | High Level Programming | 2 | 10-06-2003 07:33 AM |
| Regular expressions in sed | mfreemantle | UNIX for Dummies Questions & Answers | 3 | 02-11-2002 06:34 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try...
Code:
grep "Batch exited with ERROR" Mytest.log | while read line do : something with $line done |
|
#3
|
|||
|
|||
|
Quote:
cat Mytest.log | while read data do TEST=`echo $data | grep -i "Batch exited with ERROR "` echo $TEST done |
|
#4
|
|||
|
|||
|
Problems with regular expressions
Thanks for all ur reply.
But still i have still some problems in it 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 |
|
#5
|
||||
|
||||
|
Try...
Code:
egrep "Batch .* ERROR" Mytest.log |
|
#6
|
|||
|
|||
|
Thanks every one its working for me...
|
|||
| Google The UNIX and Linux Forums |
| Tags |
| regex, regular expressions |
| Thread Tools | |
| Display Modes | |
|
|