Is there a better way to grep until end of error message?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Is there a better way to grep until end of error message?
# 1  
Old 05-07-2009
Is there a better way to grep until end of error message?

My file creates an output log after which includes a few sql queries.
I segregate them into warnings and errors and then get a total count.
The errors' and warnings' lines always start with SQL[0-9]{4}[A-Z] followed by the details of the error.

This is what im doing as o now...

errors=`grep -A 1 -E "^SQL3196N|^SQL3147N|^SQL3148W" $output.log`

This gets me only the first line after a match is obtained.

Some errors have 1 line and others stretch out to 10 lines...
How would do you capture this info for errors and warnings and later on count the number of distinct errors and warnings encountered???
# 2  
Old 05-07-2009
I am closing this thread because it is a duplicate of a thread in Shell Programming and Scripting.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep: Return a user message when no hits

I have ASCII files to parse that 48 hours old or more ; I can identify them like so find . -name "FILE*TXT" -mtime +1 -exec ls -ltas '{}' ';' Some files have a list of hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to... (3 Replies)
Discussion started by: alan
3 Replies

2. Shell Programming and Scripting

Not able to grep a particular message in logfile.

Hi I am not able to grep a message in a log file - For ex - Notice < > "Server1" is in deploying state under "Stut" domain When i use gzcat logfile | grep -i " Notice < > "Server1" is in deploying state under "Stut" domain" It is not returning any value. Is it because of "Server1"... (1 Reply)
Discussion started by: honey26
1 Replies

3. Shell Programming and Scripting

script to grep outofmemory message in logs

I have prepare script to grep for outofmemory messages in the logs. I need help in modifying script. I have implemented small logic. The outofmemory messages form six logs will store in variables. var1=`grep -i outofmemory $tomcat1logs | sed -n '$p'| sed -n -e "s/.*\(outofmemory\).*/\1/p"`... (6 Replies)
Discussion started by: coolguyamy
6 Replies

4. Shell Programming and Scripting

How to grep for message and if found display filename?

Hi i'm new to the forum and was hoping someone could help me with the following query. I do alot of testing and have hundreds of log files output. I have a script (someone else wrote) which finds all the passed and failed logs and puts a number in a column onto a webpage: e.g: Pass ... (4 Replies)
Discussion started by: defamer
4 Replies

5. Shell Programming and Scripting

append some text message at the end of the file

Hi All, Please tell me how to append some text message at the end of the file. "File too large to view" example: xyz.log contains hhhhhhhhhhh hhhhhhjjjjjjjjj jjjjjjjjjjjjjjjjjjjjjj "File too large to view" Please advice (3 Replies)
Discussion started by: rajeshorpu
3 Replies

6. Shell Programming and Scripting

a better way to grep until end of error message, although most seem to be 1 or 2 line

My file creates an output log after which includes a few sql queries. I segregate them into warnings and errors and then get a total count. The errors' and warnings' lines always start with SQL{4} followed by the details of the error. This is what im doing as o now... errors=`grep -A 1 -E... (11 Replies)
Discussion started by: VGR
11 Replies

7. Shell Programming and Scripting

grep'ing a file until a certain message appears

Hello, I'm writing a script that will automate the launch of some services on my AIX machine. However, some services are dependent on the successful startup of others. When I start these services manually, I usually just check a log file until I see a message that confirms a successful... (3 Replies)
Discussion started by: pallak7
3 Replies

8. Shell Programming and Scripting

Grep/awk not getting the message correctly

I have a script which will take two file as the inputs and take the Value in file1 and search in file2 and give the output in Outputfile. #!/bin/sh #. ${HOME}/crossworlds/bin/CWSharedEnv.sh FILE1=$1 FILE2=$2 for Var in $(cat $FILE1);do echo $Var grep -i "$Var" $FILE2 done > Outputfile I... (2 Replies)
Discussion started by: SwapnaNaidu
2 Replies

9. Shell Programming and Scripting

How to parse a text file with \034 as field and \035 as end of message delimiter?

I need some tips to write a unix korn shell script that will parse an input text file. Input text file has messages that span several lines, each field in the message is delimited by /034 and the end of message is delimited by /035. Input file looks something similar to ... (1 Reply)
Discussion started by: indianya
1 Replies

10. UNIX for Dummies Questions & Answers

grep error message

hi, I get this error message after I pipe a lot of output into grep. Does anyone know what his means? grep: writing output: Invalid argument thanks, gammaman (3 Replies)
Discussion started by: gammaman
3 Replies
Login or Register to Ask a Question