Awk Help for extracting report from logs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Help for extracting report from logs
# 1  
Old 05-15-2009
Error Awk Help for extracting report from logs

Hi

I have a log file, with lines of following kind.

------------------------
2009-05-15 07:49:42,574 INFO - SqlMapObjectDataDao - select - selectObject - 2 ms
2009-05-15 07:49:42,575 INFO - SqlMapUserDao - select - getUserSystemAdminSuperGroup - 0 ms
2009-05-15 07:49:42,576 INFO - SqlMapUserDao - select - getUserSystemAdminSuperGroup - 1 ms
------------------------
------------------------

Please help me, prepare a awk script, which can print all the lines of the lof file, which is having "0 ms " at the end.

currently I am using a small awk script of nature,

cat localhost_admin_dao.log | awk '{ time=$12 ; \
for (i=0;time<1;i++) { \
line=$0; \
printf("%s\n", line) ; } \
}'

But, this is not working. Please help me.

Thanks and Regards,

Jitendriya Dash.
# 2  
Old 05-15-2009
Code:
awk '/-0 ms$/' file


Last edited by ghostdog74; 05-15-2009 at 10:09 AM.. Reason: avoiding 10ms
# 3  
Old 05-15-2009
Thanks a lot.

Hi,

Thanks a lot. It is such a simple point, but i was going into more complexity.

It really helped me a lot.

Thanks and Regards,

Jitendriya Dash.
# 4  
Old 05-15-2009
or more accurately (avoiding the possible '10 ms' ):
Code:
awk '$(NF-1) == "0" && $NF == "ms" ' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting logs using gunzip awk and gzip

Hi All I am trying to use a hard coded script into shell scripting but I am unable to . Kindly find the Script below along with the command Please help gunzip -c FilePath/FileName_*.gz | awk '$0 > "" && $0 < ""'|\ gzip >> FilePath/Outputfile.log.gz I Am trying to use this... (9 Replies)
Discussion started by: pulkitbahl
9 Replies

2. Shell Programming and Scripting

Shell script - Asterisk logs report

Dear all, I start to build script(s) for few tasks, and I'll use log files to complete the following: 1) when ringnoanswer for a particular operator hits count 10 for waittime > 14000 send mail alert with summary of calls 2) per queue - exitwithtimout > 1 in any hour, then send mail... (12 Replies)
Discussion started by: bigbrobg
12 Replies

3. Shell Programming and Scripting

Need help extracting data for report creation

Hi All, is there any way we can get the job names running with particular owner. Example: i want to get the job names running with owner as "autosys" (16 Replies)
Discussion started by: sdosanjh
16 Replies

4. Shell Programming and Scripting

using awk to get specific section of lines in logs

i have a log file that has the date and time that looks like this: Wed Jun 28 15:46:21 2012 test failed tailed passed passed not error panic what we want to focus on is the first 5 columns because they contain the date and time. the date and time can be anywhere on the line. in this... (6 Replies)
Discussion started by: SkySmart
6 Replies

5. UNIX for Dummies Questions & Answers

help in extracting logs in readable format

hello everyone. newbie here in unix. I am trying to extract the logs of a certain job and would like to output it in a readable format, see below the CAT part: cat /var/opt/ctma/ctm/sysout/idwesct_sh30_eng_r6_cdcs_sh.LOG_05l0du_000* | egrep -i 'orderid:|file_name=' | sed... (1 Reply)
Discussion started by: eanne_may
1 Replies

6. Shell Programming and Scripting

Need to develop a script to create a report reading multiple server logs

I am currently trying to develop a script to connect to mulltiple servers, reading specifc data from log files on the servers and append the data from each file into a single tab delimited row. So, at the end I am planning to have a report with all the extracted data with each row per server. I am... (5 Replies)
Discussion started by: scriptingnewbie
5 Replies

7. Shell Programming and Scripting

AWK to separate numbers from logs

Hello friends, Im trying to separate a number from a log, but it seems i need help here awk '/stimated/ {print $5}' mylog.txt gives (1515.45MB). i need pure number part to use in a comparision loop so i want to separate the number part (but only 1515 not 1515.45 ) awk '/stimated/... (6 Replies)
Discussion started by: EAGL€
6 Replies

8. Shell Programming and Scripting

Parsing out the logs and generating report

My file will contain following(log.txt): start testcase: config loading ...... error XXXX ..... end testcase: config loading, result failed start testcase: ping check ..... error ZZZZZ ..... error AAAAA end testcase: Ping check, result failed I am expecting below output. ... (4 Replies)
Discussion started by: shellscripter
4 Replies

9. Shell Programming and Scripting

Need AWk To parse XML logs

Hi , I need an Awk script to parse my log file . 2008-04-26 10:00:13,391 INFO Logger - <?xml version="1.0" encoding="UTF-8" standalone="no"?><2dm tmsg... (0 Replies)
Discussion started by: amit1_x
0 Replies

10. Shell Programming and Scripting

Extracting data from large logs.

Hi all, I have a large log file that gets created daily. I need to be able to pull text out of the log when I hit a pattern including the 7 lines above it and the 3 lines below and output it to a new text file. Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Pattern Line 9 Line 10... (11 Replies)
Discussion started by: bas
11 Replies
Login or Register to Ask a Question