Sponsored Content
Top Forums Shell Programming and Scripting Find time difference between two consecutive lines in same file. Post 302504222 by vilibit on Monday 14th of March 2011 04:58:56 AM
Old 03-14-2011
MySQL Problem solved

I promised to get back with results.
The danmero solution is working charmingly, although I'm not fully understand how it read previous line and compare with current one. The data from my file are several lines long and script pointed me exactly where to look for differences. Thanks again danmero, this is exactly what I need.
Although is not exactly what I intended to obtain, I tested the rbatte1 solution and after choosing h or S option I get an error:


Code:
Please enter the start time: 08:09:10
Please enter the end time: 08:09:20
Respond in hh:mm:ss or seconds? (h/S)S
The difference is: ./rba[26]: shhs=*3600: unexpected `*'
./rba[27]: ehhs=*3600: unexpected `*'
./rba[28]: smms=*60: unexpected `*'
./rba[29]: emms=*60: unexpected `*'
0

Probably becouse i use bash which i must be mentioned earlyer. Sorry.
Thanks again for your time. My problem was solved Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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 AER3-000095 IDOC... (2 Replies)
Discussion started by: satyakam
2 Replies

2. 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

3. Shell Programming and Scripting

Calculate difference between consecutive data points in a column from a file

Hi, I have a file with one column data (sample below) and I am trying to write a shell script to calculate the difference between consecutive data valuse i.e Var = Ni -N(i-1) 0.3141 -3.6595 0.9171 5.2001 3.5331 3.7022 -6.1087 -5.1039 -9.8144 1.6516 -2.725 3.982 7.769 8.88 (5 Replies)
Discussion started by: malandisa
5 Replies

4. Shell Programming and Scripting

how to delete two consecutive lines from the file

Hi guys I am deleting a unique line from the file and also need to remove the line above it which is NOT unique and servers as a record separator. Here is an example: # 101 803E 823F 8240 # 102 755f 4F2A 4F2B # 290 747D 0926 0927 # 999 8123 813E ... (5 Replies)
Discussion started by: aoussenko
5 Replies

5. 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

6. 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

7. Shell Programming and Scripting

Get the time difference between two consecutive line in UNIX perl script

Hi All :o, I have some log files which contains these informations: 2013-04-24 09:11:34.018 INFO XXXXXXXXXXXX 2013-04-24 09:11:34.029 INFO YYYYYYYYYYYY 2013-04-24 09:11:34.039 INFO ZZZZZZZZZZZZZZZ 2013-04-24 09:12:21.295 INFO TTTTTTTTTTTTTTT 2013-04-24 09:12:21.489 INFO... (3 Replies)
Discussion started by: shariquehabib
3 Replies

8. 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

9. 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

10. UNIX for Beginners Questions & Answers

find pattern matches in consecutive lines in certain fields-awk

I have a text file with many thousands of lines, a small sample of which looks like this: InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0 PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies
STARPU_WORKERS_ACTIVITY:(1)					   User Commands				       STARPU_WORKERS_ACTIVITY:(1)

NAME
starpu_workers_activity: - manual page for starpu_workers_activity: 40: [: --version: unexpected operator DESCRIPTION
./starpu_workers_activity: 40: [: --help: unexpected operator ./starpu_workers_activity: 40: [: --help: unexpected operator ./starpu_work- ers_activity: 45: [: --help: unexpected operator ./starpu_workers_activity: 45: [: --help: unexpected operator ./starpu_workers_activity: 45: [: --help: unexpected operator Error. File <--help> not found Offline tool to display the activity of the workers during the execution. The starpu_fxt_tool utility now generates a file named 'activity.data' which can be processed by this script to generate a plot named activity.eps Typical usage: ./starpu_fxt_tool -i /tmp/prof_file_foo ./starpu_workers_activity activity.data OPTIONS
-h, --help display this help and exit -v, --version output version information and exit -h, --help display this help and exit -v, --version output version information and exit REPORTING BUGS
Report bugs to <starpu-devel@lists.gforge.inria.fr> ./starpu_workers_activity: 40: [: --version: unexpected operator ./starpu_workers_activity: 45: [: --version: unexpected operator ./starpu_workers_activity: 45: [: --version: unexpected operator ./starpu_workers_activity: 45: [: --version: unexpected operator Error. File <--version> not found Offline tool to display the activity of the workers during the execution. The starpu_fxt_tool utility now generates a file named 'activity.data' which can be processed by this script to generate a plot named activity.eps Typical usage: ./starpu_fxt_tool -i /tmp/prof_file_foo ./starpu_workers_activity activity.data Report bugs to <starpu-devel@lists.gforge.inria.fr> starpu_workers_activity: 40: [: --version: unexpected operator November 2013 STARPU_WORKERS_ACTIVITY:(1)
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy