Based on the first & last timestamp of the file, need to calculate the time taken to complete


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Based on the first & last timestamp of the file, need to calculate the time taken to complete
# 1  
Old 10-22-2012
Based on the first & last timestamp of the file, need to calculate the time taken to complete

Below is the sample file:

Code:
287 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > Setting Java Properties
287 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > Intialising ORB
Oct 15, 2012 5:18:21 PM org.jacorb.config.JacORBConfiguration init
WARNING: jacorb.home unset! Will use '.'
Oct 15, 2012 5:18:21 PM org.jacorb.config.JacORBConfiguration init
WARNING: File ./jacorb.properties for configuration jacorb not found
Oct 15, 2012 5:18:21 PM org.jacorb.orb.ORB printVersion
INFO:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JacORB V 2.3.1,
(C) The JacORB project 27-May-2009
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Oct 15, 2012 5:18:21 PM org.jacorb.orb.ORB initKnownReferencesMap
INFO: Property "jacorb.hashtable_class" is set to: java.util.HashMap
474 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > Getting list of ORB services
475 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - RootPOA
475 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - POACurrent
475 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - DynAnyFactory
475 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - PICurrent
476 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - CodecFactory
476 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > ORB services - RTORB
476 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > Resolving Naming Service
Oct 15, 2012 5:18:21 PM org.jacorb.orb.giop.CodeSet getTCSDefault
WARNING: Warning - unknown codeset (ASCII) - defaulting to ISO-8859-1
839 DEBUG syndesis.pb.util.ITraceManager - syOID=ELntNetwork:1005Mon Oct 15 17:18:21 IST 2012 <ELClientManagerenEmsSession() > Naming Service IOR Text - IOR:0000
00000000001D49444C3A6F6D672E6F72672F434F5242412F4F626A6563743A312E3000000000000000010000000000000027000100000000000D3137322E31362E32342E3934000013D30000000B4E616D655365
7276696365
Oct 15, 2012 5:18:21 PM org.jacorb.orb.giop.ClientConnectionManager getConnection


Based on the first & last timestamp of the file, need to calculate the time taken to complete.

Last edited by Franklin52; 10-22-2012 at 06:31 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 10-22-2012
A GNU solution:
Code:
#gawk '
function sec(num) {
cmd="date -d \""num"\" +%s"
cmd|getline r
close(cmd)
return r
}
match($0, /(^\w+.* [0-9]+:[0-9]+:[0-9]+ +(PM|AM))/ , ary) {
a=ary[1];c++}c==1{o=a}
END{ f=sec(a)-sec(o) ;print "Diff seconds: "f}' infile


Last edited by Klashxx; 10-22-2012 at 09:01 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Picking the latest file based on a timestamp for a Dynamic file name

Hi , I did the initial search but could not find what I was expecting for. 15606Always_9999999997_20160418.xml 15606Always_9999999998_20160418.xml 15606Always_9999999999_20160418.xml 9819Always_99999999900_20160418.xml 9819Always_99999999911_20160418.xmlAbove is the list of files I... (4 Replies)
Discussion started by: chillblue
4 Replies

2. UNIX for Dummies Questions & Answers

Display files based on particular file timestamp

Hi, I have requirement to list out files that are created after particular file. ex. I have below files in my directory. I want to display files created after /dirdat/CG1/cg004440 file. ./dirdat/CG1/cg004438 09/07/14 0:44:05 ./dirdat/CG1/cg004439 09/07/14 6:01:48 ... (3 Replies)
Discussion started by: tmalik79
3 Replies

3. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

4. Shell Programming and Scripting

List Files Based On Time & Date

Hi All, I am using HP Unix. I want to list files which are created 5 minutes before on the same day as well as before today's date. I checked all the forums and the commands provided there does not work on HP Unix. Can you please help me on this? Your help is highly aprreciated. Thanks and... (3 Replies)
Discussion started by: angshuman
3 Replies

5. UNIX for Dummies Questions & Answers

Order based on timestamp in a single file

Hi All, I have a large text file which is a combination of multiple files. This is what I used and it worked. for i in /home/docs/text/* do cat $i >> Single_File done Now wondering, if there is a way to sort that single large file based on timestamps in ascending order. Text file... (11 Replies)
Discussion started by: prrampalli
11 Replies

6. Shell Programming and Scripting

Transpose timestamp based on column values and calculate time difference

Hello Expert, I need to transpose Date-Timestamp based on same column values and calculate time difference. The input file would be as below and required output is mentioned in the bottom INPUT File ======== 08/23/2012 12:36:09 JOB_5340 08/23/2012 12:36:14 JOB_5340 08/23/2012... (2 Replies)
Discussion started by: asnandhakumar
2 Replies

7. Shell Programming and Scripting

Prepend TimeStamp to STDERR & STDOUT to a file

Currently I am redirecting STDERR and STDOUT to a log file by doing the following { My KSH script contents } 2>&1 | $DEBUGLOG Problem is the STDERR & STDOUT do not have any date/time associated. I want this to be something that i can embed into a script opposed to an argument I use... (4 Replies)
Discussion started by: nitrobass24
4 Replies

8. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

9. UNIX for Dummies Questions & Answers

BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows... (0 Replies)
Discussion started by: Mithu
0 Replies

10. Shell Programming and Scripting

Remove lines, Sorted with Time based columns using AWK & SORT

Hi having a file as follows MediaErr.log 84 Server1 Policy1 Schedule1 master1 05/08/2008 02:12:16 84 Server1 Policy1 Schedule1 master1 05/08/2008 02:22:47 84 Server1 Policy1 Schedule1 master1 05/08/2008 03:41:26 84 Server1 Policy1 ... (1 Reply)
Discussion started by: karthikn7974
1 Replies
Login or Register to Ask a Question