need help in search the error messages from log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help in search the error messages from log file
# 1  
Old 02-24-2012
need help in search the error messages from log file

Hi,

My log file has error messages, universal no and universal ID. The problem is i have to search Universal ID from the error messages. But the log file write error messages with universal no and error messages in one line. and universal no with universal ID in other line. So i write two loops for to grab the universal ID. First grep all universal no in one go. But for Universal ID i have to run grep command for each universal no. I am using grep -m 1 option also to out from the log once i found the pattern. But issue is every time it will start the searching from starting. So there is any way that i start search when i left.
and server write random thing between the lines. So i can't use -B option grep.
Quote:
Error messages:-


FATAL error at 00122334
// random log lines
00122334 from apple
//random log lines
FATAL error at 993321
//random log files
993321 from rat
/random log files
FATAL from 665756
//random log files
665756 from orange.


need output,

apple
rat
orange
# 2  
Old 02-24-2012
Try:
Code:
awk '/FATAL/{id=$NF}$1==id{print $3}' file

# 3  
Old 02-24-2012
-- deleted ---

Last edited by ctsgnb; 02-24-2012 at 07:27 AM.. Reason: Bartus answer is fine
# 4  
Old 02-24-2012
---Updated below---

Last edited by pjlotiya; 02-24-2012 at 08:10 AM..
# 5  
Old 02-24-2012
Code:
 
$ nawk '$0~/FATAL/{b=$NF}{if($0~b && b!~$NF){print $NF}}' log.txt
apple
rat
orange.

# 6  
Old 02-24-2012
Hi thanks for reply but here the my problem. my log files actually look like.

2012:02:23:08:53:06.667 el8 3:INFO SERVER NOFMT 33001598665301 REQUEST_RECEIVED_FROM_MERCHANT kulula_dm
//random messages
2012:02:23:08:53:16.936 el8 1:ERR1 VELOCITY 33001598665301 Failed to query velocity server: java.net.SocketTimeoutException: Read timed out


..
so here "failed to query velocity server" is my error message and i have to give final result as "kulula_dm" as my final out put.

This log files is zipped.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search special characters in a file and replace with meaningful text messages like Hello

Search special characters in a file and replace with meaningful text messages like Hello (2 Replies)
Discussion started by: raka_rjit
2 Replies

2. SuSE

Some error messages in var/log/messages

How are you? SUSE V10 and 11. In /var/log/messages I see these lines in some servers. I'd like to know what causes these errors and how to fix them. Thank you, error: PAM: Authentication failure for root from XXXXXXXX Did not receive identification string from XXXXXXX Invalid user suse-gm... (2 Replies)
Discussion started by: JDBA
2 Replies

3. Shell Programming and Scripting

How to search log file from a date

Hi All, I want to grep through all the log files created from 20th August. How do I do that? My script will run everyday. So it will take current date as To_Date. My log file name looks like - applog-2012-08-20-000001....applog-2012-08-20-000002...etc. Thanks in advance. (5 Replies)
Discussion started by: kmajumder
5 Replies

4. Red Hat

monitoring search strings /var/log/messages

Hello Everyone, I am setting up monitoring system for linux server, I need to add few some common error message in monitoring file which can search those strings in /var/log/messages file on the client. can someone suggest few error messages. Thanks, (2 Replies)
Discussion started by: bobby320
2 Replies

5. UNIX for Dummies Questions & Answers

How to search in a log file?

Hey guys, I'm still relatively new to Linux and everyday is a learning experience for me. Anyway, I have a question about searching inside a log file and didn't know what topic this would come under so posting it here as I am a Dummie lol! Say I have a log file which consists of say, for... (2 Replies)
Discussion started by: jimbob01
2 Replies

6. Shell Programming and Scripting

Search a pattern in a log file

I have file which gets updated every minute/second. Is it possible in shell scripting that I can search for some pattern infinitely in this file and if it finds that pattern, alert the user. A sample of log file is below. The following file is getting updated every second. I want to alert the... (2 Replies)
Discussion started by: Tuxidow
2 Replies

7. Shell Programming and Scripting

Appending error messages from log file next to the corresponding error record

Hi Everyone, I have an issue and trying to get a solution but was not succesful yet. Any help is greatly appreciated. I am using ksh to inoke sql loader to load data from txt file into two oracle tables based on the condition written in the control file. If an error occurs while loading into... (8 Replies)
Discussion started by: vpv0002
8 Replies

8. HP-UX

How to Redirect the error messages from Syslog file to our own Application Log File

Hello, I am New to Unix. I am Using HP-UX 9000 Series for my Application. I am Currently Facing an Issue that the error messages are being written in the syslog file instead of the Application Log File. The Codes for that Syslog.h is written in Pro*C. I want to know how to Redirect these... (3 Replies)
Discussion started by: balasubramaniam
3 Replies

9. Shell Programming and Scripting

String search in log file

Hi all! I have a log file from an incremental backup. This next script I've done works when the backup completes in the same day it started. But if the backup goes on to the next day, this one doesn't work anymore. ################################## #VARS data=`date '+%m/%d/%y'`... (1 Reply)
Discussion started by: sliver
1 Replies

10. Shell Programming and Scripting

search log file

hi, I know this question probably been asked a thousand times but I can't find any posts that can help me out, so here I am. The problem is at the end of the day I want to execute a script but I only want to invoke it if and only if scripts 1/2/3/4/5/6 executed successfully. So what I did is to... (1 Reply)
Discussion started by: mpang_
1 Replies
Login or Register to Ask a Question