Visit Our UNIX and Linux User Community


To find the time difference between two lines of the same log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To find the time difference between two lines of the same log file
# 1  
Old 04-29-2008
Java To find the time difference between two lines of the same log file

Hello Friends,

I want to write a script for the following:

nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more
2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info [Adapter] AER3-000095 IDOC posted to
client SA_EHV_SPEED_SFC_IN_03InboundConnection4Client0 successfully tracking=#QrQ--5--G/SbkkvU67u6Ucw38-6gQ#
2008 Apr 30 01:01:23:958 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info [Adapter] AER3-000094 Posting IDOC t
o client SA_EHV_SPEED_SFC_IN_03InboundConnection8Client0 tracking=#I0Y--/--G/Sbl-rs68EEcJI5X-mrY#
2008 Apr 30 01:01:24:788 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info [Adapter] AER3-000095 IDOC posted to
client SA_EHV_SPEED_SFC_IN_03InboundConnection8Client0 successfully tracking=#I0Y--/--G/Sbl-rs68EEcJI5X-mrY#

On using the above command I can view the time difference between posting and posted. I want that the UNIX program to check for the time difference greater than 1 second. Please help me in this. I am absolutely new to the UNIX environment and know little regarding Shell programming. Hence I would like to have the full code.

Thanks
# 2  
Old 04-30-2008
This is a FAQ; see https://www.unix.com/answers-frequent...rithmetic.html (maybe the title should be different, it's date and time arithmetic).
# 3  
Old 04-30-2008
Bug

Hi Era,

Thnx for the help!! I tried to view the scripts but there are too many modifications in the thread. Can u plz provide me with the complete and rectified code? That would b of gr8 help!!!!

Thnx in advance frnd!!!!!

Previous Thread | Next Thread
Test Your Knowledge in Computers #589
Difficulty: Medium
A binary search algorithm requires that the array being searched is sorted in descending order.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In HP-UX how to find the date time difference ?

Hello, In HP-UX how to find the date time difference ? Start time: 28-APR-2019 21:36:01 End time : 29-APR-2019 00:36:04 ---------------------- Difference is ---------------------- Much appreciate any pointer or view on this. ... (3 Replies)
Discussion started by: Siva SQL
3 Replies

2. Shell Programming and Scripting

Calculate time difference between two lines

i grepped the time stamp in a file as given below now i need to calculate time difference file data: 18:29:10 22:15:50 (5 Replies)
Discussion started by: vivekn
5 Replies

3. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

4. Shell Programming and Scripting

Check/Parse log file's lines using time difference/timestamp

I was looking at this script which outputs the two lines which differs less than one sec. #!/usr/bin/perl -w use strict; use warnings; use Time::Local; use constant SEC_MILIC => 1000; my $file='infile'; ## Open for reading argument file. open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies

5. UNIX for Dummies Questions & Answers

Find time difference

I have a file wich contains time formats and i need to get the time difference TIME1 TIME2 =============== =================== 20120624192555.6Z 20120624204006.5Z which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (23 Replies)
Discussion started by: wnaguib
23 Replies

6. Shell Programming and Scripting

How to find time difference?

I have a file wich contains time formats and i need to get the time difference TIME1 TIME2 ================================== 20120624192555.6Z 20120624204006.5Z which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (1 Reply)
Discussion started by: wnaguib
1 Replies

7. Shell Programming and Scripting

Find time difference between two consecutive lines in same file.

Hello I have a file in following format: IV 08:09:07 NM 08:12:01 IC 08:12:00 MN 08:14:20 NM 08:14:15 I need a script to compare time on each line with previous line and show the inconsecutive line. Ex.: 08:12:00 08:14:15 A better way... (6 Replies)
Discussion started by: vilibit
6 Replies

8. Shell Programming and Scripting

Find Time difference in Unix

Hi, START_TIME :- "10-NOV-2009 00:00:04" STOP_TIME :- "10-NOV-2009 00:05:47" Please help to find difference between these two. Searched for the same topic but did not find an answer for the same time format :( Regards, Robin (3 Replies)
Discussion started by: robinbannis
3 Replies

9. AIX

How to find time difference between 2 timestamps?

HI All, can some one please help me how to fine the difference between two time stamps say a= Nov 10, 2009 9:21:25 AM b= Nov 10, 2009 10:21:25 AM I want to find difference between the a & b I googled and tried with some options but no luck. My OS is AIX (1 Reply)
Discussion started by: bandlan9
1 Replies

10. Shell Programming and Scripting

Help to find the time difference between the lines

Hi guru's, Am new to shell scripting. I am getting the below o/p from the oracle database, when I fire a query. ID JOB_ID ELAPSED_TIME FROM TO ----- ------ ------------------- -------- -------- 62663 11773 01/06/2009 09:49:13 SA CM 62664 11773 ... (4 Replies)
Discussion started by: sathik
4 Replies

Featured Tech Videos