Help on Log File format using sed or awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on Log File format using sed or awk
# 1  
Old 02-05-2014
CPU & Memory Help on Log File format using sed or awk

Hello Gurus,

First, i would like to know is there any way to solve my problem.

i have a log file like this:

Code:
[2014-02-04 00:10:45,306] INFO - ABCDRequest ::  processing started for the record <0> TransactionNo <Txn#1> recordID <recID#1>
[2014-02-04 00:10:45,313] INFO - ABCDRequest ::  processing started for the record <0> TransactionNo <Txn#2> recordID <recID#2>
[2014-02-04 00:10:45,704] INFO - ABCDRequest ::  Response creation completed for the record  <0> TransactionNo <Txn#2> recordID <recID#2>
[2014-02-04 00:10:45,708] INFO - ABCDRequest ::  Response creation completed for the record  <0> TransactionNo <Txn#1> recordID <recID#1>
[2014-02-04 00:10:45,753] INFO - ABCDRequest ::  processing started for the record <0> TransactionNo <Txn#3> recordID <recID#3>
[2014-02-04 00:10:45,896] INFO - ABCDRequest ::  processing started for the record <0> TransactionNo <Txn#4> recordID <recID#4>
[2014-02-04 00:10:46,127] INFO - ABCDRequest ::  Response creation completed for the record  <0> TransactionNo <Txn#3> recordID <recID#3>
[2014-02-04 00:10:47,064] INFO - ABCDRequest ::  Response creation completed for the record  <0> TransactionNo <Txn#4> recordID <recID#4>

from the above log file, i want to know the tile difference between "processing started for the record and Transaction No" to "Response creation completed for the record and Transaction No". for example in above log, for Txn#1, time recived at 2014-02-04 00:10:45,306 and processing time completed at 2014-02-04 00:10:45,708, so the difference is 402 Milli Sec., so i would like to see the output something like this:

Time consuming for Txn#1 is 402 Milli Sec.

can any body help me to do this?

Thanks in Advance,
Vasu
# 2  
Old 02-05-2014
It might be fairly easy with perl and Date::Calc. Check if you have it available:
Code:
perl -e 'use Date::Calc'

No output means you have it installed on your system.
# 3  
Old 02-05-2014
Hi bartus11, Thanks for your reply, but unfortunately we don't have perl in our Dev box.
So i have to use another way other than Perl.
# 4  
Old 02-05-2014
Is it a Linux box?
This User Gave Thanks to bartus11 For This Post:
# 5  
Old 02-05-2014
It is Unix box.
# 6  
Old 02-05-2014
What does this say on that box:
Code:
uname -a

# 7  
Old 02-05-2014
Code:
Linux <hostname> 2.6.32-358.18.1.el6.x86_64 #1 SMP Fri Aug 2 17:04:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux


Last edited by Scott; 02-05-2014 at 04:39 PM.. Reason: Added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format the text using sed or awk

I was able to figure out how to format a text. Raw Data: $ cat test Thu Aug 23 15:43:28 UTC 2018, hostname01, 232.02, 3, 0.00 Thu Aug 23 15:43:35 UTC 2018, hostname02, 231.09, 4, 0.31 Thu Aug 23 15:43:37 UTC 2018, hostname03, 241.67, 4, 0.43 (5 Replies)
Discussion started by: kenshinhimura
5 Replies

2. Shell Programming and Scripting

Datestamp format 2nd change in csv file (awk or sed)

I have a csv file formatted like this: 2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances. I have got this: awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Discussion started by: say170
6 Replies

3. Shell Programming and Scripting

Format a log file using sed

I am looking to extract something like this from the below sample log file. 10.28.76.15 SSLC=Z42 71.19.175.130 10.28.76.15 SSLC=Z42 71.19.175.130 10.28.76.15 SSLC=Z42 71.19.175.130 for that I tried something like below and I have no clue how to extract the IP address marked red in the log... (6 Replies)
Discussion started by: Tuxidow
6 Replies

4. Shell Programming and Scripting

Need awk/sed to format a file

My content of source file is as below scr1 a1 scr2 a2 b2 scr3 a3 b3 c3 I need a awk/sed command (to be used in C shell)to format it to something like below scr1 $a1 >file1 scr2 $a2 $b2 >file2 scr3 $a3 $b3 $c3 >file3 (12 Replies)
Discussion started by: animesharma
12 Replies

5. Shell Programming and Scripting

Using SED/AWK to Summarize Log File in 10min Intervals

I have this huge log file on my linux box that gets generated every day. I'm able to extract the information I need; however I really would like it to be broken down every 10mins. Log File Snippet 01:23:45 MARYHADA Maryhadalittle.lamb(): fleece as white as snow 1394 for and everywhere that... (8 Replies)
Discussion started by: ravzter
8 Replies

6. Shell Programming and Scripting

Format log file - SED

Hello, I need help to format a log file...again ; )) Here is what I have : FILE='/OPERATIONNEL/SATURNE/MASTER/SATURNE_MASTER_PRE_R20110119.TAR.GZ ... (5 Replies)
Discussion started by: Aswex
5 Replies

7. Shell Programming and Scripting

Please help me format with AWK or SED

INPUT FILE: 9780743565219 "GODS OF NEWPORT" "JAKES, JOHN" 2006 OUTPUT FILE I NEED to CREATE FROM INPUT FILE: cd /data/audiobooks/9780743565219 ~/Desktop/mp3-to-m4b 9780743565219-GODS OF NEWPORT "GODS OF NEWPORT" "JAKES, JOHN" 2006 n ---------- Post updated at 04:19 PM ----------... (6 Replies)
Discussion started by: glev2005
6 Replies

8. Shell Programming and Scripting

awk or sed to format text file

hi all, i have a text file which looks like the below 01 02 abc Top 40 music Kidz Only! MC 851 MC 852 MC 853 7NOW Arch_Diac xyz2 abc h211 Commacc1 Commacc2 Commacc3 (4 Replies)
Discussion started by: posner
4 Replies

9. Shell Programming and Scripting

SED - log file format

Hello everyone, I have a log file : \data\file\script\command_0001 \data\file\script\command_0002 \data\file\script\command_0003 I need to make all lines on this way \data\file\script\command_0001 \data\file\script\command_0002 \data\file\script\command_0003 I know this could be done... (11 Replies)
Discussion started by: Aswex
11 Replies

10. Shell Programming and Scripting

How to print log file in column format using awk

Hi Friends, I have a log file as below siteid = HYD spc = 100 rset = RS_D_M siteid = DEL spc = 200 rset = RS_K_L siteid = DEL2 spc = 210 rset = RS_D_M Now I need a output like column wise as below. siteid SPC rset HYD 100 RS_D_M (2 Replies)
Discussion started by: suresh3566
2 Replies
Login or Register to Ask a Question