Sponsored Content
Top Forums Shell Programming and Scripting Calculating Time difference Between two Rows in Linux Post 303006528 by RudiC on Friday 3rd of November 2017 06:49:05 AM
Old 11-03-2017
Try
Code:
awk '
function s(x)   {split (x, t, ":")
                 return t[1]*3600 + t[2]*60 + t[3]
                }

!NF             {next
                }

!MIN[$3]        {MIN[$3] = $1
                }

                {MAX[$3] = $1
                }

END             {for (m in MIN) print m " has " s(MAX[m]) - s(MIN[m]) " second difference."
                }
' file
77845 has 0 second difference.
77846 has 1 second difference.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calculating the time difference, when the script was executed and the currenent file

Hi, I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the... (7 Replies)
Discussion started by: velocitnitin
7 Replies

2. Shell Programming and Scripting

parsing and calculating difference.

Hi, I have a file with the contents as following Access Time: Thu Nov 6 16:43:45 2008 Modify Time: Thu Nov 6 16:43:45 2008 Change Time: Thu Nov 6 16:43:45 2008 Access Time: Thu Nov 6 16:43:02 2008 Modify Time: Thu Nov 6 16:44:01 2008 Change Time: Thu Nov 6 16:44:01 2008 I need... (3 Replies)
Discussion started by: meetmano143
3 Replies

3. UNIX for Dummies Questions & Answers

Calculating the Number of Rows and Average

Hi All I like to know how can we calculate the number of rows and the average of the values present in the file. I will not know what will be the rowcount, which will be dynamic in nature of the file. eg. 29 33 48 30 28 (6 Replies)
Discussion started by: pk_eee
6 Replies

4. Shell Programming and Scripting

Calculating completion time

The date construct in UNIX can be used to calculate when something is finished: date -v+1H displays the time 1 hour from now. I want to use the same construct in a script, but it is leading to error messages: echo "Finished at: " `date -v+$durationH` where $duration is calculated based on input... (3 Replies)
Discussion started by: figaro
3 Replies

5. Shell Programming and Scripting

Calculating the difference between dates

Hello! i need to find files lower and bigger that one date i pass, i search in the man find, but i didn't find anything, the only that i find is the parameter -mtime, in this parameter i can pass a number of days, but i need to know the difference between dates, any built-in function for do... (15 Replies)
Discussion started by: claw82
15 Replies

6. Shell Programming and Scripting

AWK - calculating simple correlation of rows

Is there any way to calculate a simple correlation of few selected rows with all the rows in input ? In the below example I selected Row01,02,03 and correlated with all the rows. I was trying to run in R. But the this big data matrix is too much to handle for R and eventually my system is... (3 Replies)
Discussion started by: quincyjones
3 Replies

7. UNIX for Advanced & Expert Users

Help with Calculating time difference between many directories in UNIX

A report needs to come some what similar to this No of elements Stream Batch No Load time A B C D A,B,C im able to get quite easily wc -l /usr/local/intranet/areas/prod/output/SRGW_0?/*/MESSAGE_T.dat O/P of above command. A B C ... (1 Reply)
Discussion started by: peckenson
1 Replies

8. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

9. Shell Programming and Scripting

Trouble calculating difference in number of days

Hi all, I have a requirement to calculate the difference of number of days of time stamp of a file and system date and if the difference is greater than 15 days it should prompt as previous month file otherwise current month file. Below is the code i used and it is working fine till now. (You... (2 Replies)
Discussion started by: Ravindra Swan
2 Replies

10. Shell Programming and Scripting

Calculating the running time

Hi All, I want to run a utility for all the process id that are running for more than 15 mins. I have captured process id's and the time that they were run in a file like below 1st column represnts the process ids and the 2nd one is the Time < 21014 01:00 21099 01:00 24361 01:03 24406... (5 Replies)
Discussion started by: r_t_1601
5 Replies
Alzabo::SQLMaker::PostgreSQL(3pm)			User Contributed Perl Documentation			 Alzabo::SQLMaker::PostgreSQL(3pm)

NAME
Alzabo::SQLMaker::PostgreSQL - Alzabo SQL making class for PostgreSQL SYNOPSIS
use Alzabo::SQLMaker; my $sql = Alzabo::SQLMaker->new( sql => 'PostgreSQL' ); DESCRIPTION
PostgreSQL-specific SQL creation. METHODS
Almost all of the functionality inherited from "Alzabo::SQLMaker" as is. The only overridden methods are "limit()" and "get_limit()", as PostgreSQL does allow for a "LIMIT" clause in its SQL. EXPORTED SQL FUNCTIONS
SQL may be imported by name or by tags. They take arguments as documented in the PostgreSQL documentation (version 3.23.39). The func- tions (organized by tag) are: :math PI RANDOM ABD CEIL DEGREES FLOOR FACTORIAL SQRT CBRT EXP LN RADIANS ACOS ASIN ATAN ATAN2 COS COT SIN TAN ROUND TRUNC LOG POW MOD TO_CHAR :string LENGTH CHAR_LENGTH CHARACTER_LENGTh OCTET_LENGTH TIRM UPPER LOWER INITCAP ASCII TO_ASCII STRPOS POSITION TO_NUMBER TO_DATE TO_TIMESTAMP REPEAT RPAD LPAD SUBSTR :datetime NOW CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP TIMEOFDAY ISFINIT TIMESTAMP TO_CHAR DATE_PART DATE_TRUNC EXTRACT OVERLAPS :network BROADCAST HOST NETMASK MASKLEN NETWORK TEXT ABBREV :aggregate These are functions which operate on an aggregate set of values all at once. COUNT AVG MIN MAX SUM STDDEV VARIANCE :system These are functions which return information about the Postgres server. CURRENT_USER SYSTEM_USER USER :control These are flow control functions: NULLIF COALESCE :misc These are functions which don't fit into any other categories. ENCRYPT ENCODE DECODE FORMAT INET_NTOA INET_ATON BIT_OR BIT_AND PASSWORD MD5 LOAD_FILE :common These are functions from other groups that are most commonly used. NOW COUNT AVG MIN MAX SUM DISTINCT AUTHOR
Dave Rolsky, <dave@urth.org> perl v5.8.8 2007-12-23 Alzabo::SQLMaker::PostgreSQL(3pm)
All times are GMT -4. The time now is 10:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy