Time difference calculation

Hi,

I have a file which contains a set of time data as follows

16:37:45
15:45:52
13:48:20
00:20:23

i need to find the time difference with the present time.

Can anyone put some !dea ?

Thanks in advance
Anup V [ So, 30 Dezember 2007 13:37 ] [ ID #1895964 ]

Re: Time difference calculation

On 12/30/2007 6:37 AM, varkey wrote:
> Hi,
>
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
>
> Can anyone put some !dea ?

Are those times always in the past and are they always from the current day?

Ed.
Ed Morton [ So, 30 Dezember 2007 13:43 ] [ ID #1895965 ]

Re: Time difference calculation

varkey wrote:
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.

in seconds? All in the past but today?

$ echo $(( $(date +%s) - $(date -d '13:48:20' +%s) ))
211

--
Best regards
Cyrus
From a jewish slaughterhouse in Iowa (undercover)
http://video.google.com/videoplay?docid=-7960687976401601534
Cyrus Kriticos [ So, 30 Dezember 2007 13:53 ] [ ID #1895966 ]

Re: Time difference calculation

varkey wrote:
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.

in seconds? All from today?

[GNU date & bash]

$ echo $(( $(date +%s) - $(date -d '13:48:20' +%s) ))
211

--
Best regards
Cyrus
From a jewish slaughterhouse in Iowa (undercover)
http://video.google.com/videoplay?docid=-7960687976401601534
Cyrus Kriticos [ So, 30 Dezember 2007 13:56 ] [ ID #1895967 ]

Re: Time difference calculation

Yeah i need to take the difference from the current time only.
Anup V [ So, 30 Dezember 2007 15:04 ] [ ID #1895968 ]

Re: Time difference calculation

On Sun, 30 Dec 2007 06:04:17 -0800, varkey wrote:

> Yeah i need to take the difference from the current time only.

The date command from the ast-open package has a '-E' (for elapsed)
option that does what you want.

You can get it under an open source license from

http://www.research.att.com/sw/download/
Icarus Sparry [ So, 30 Dezember 2007 18:13 ] [ ID #1895970 ]

Re: Time difference calculation

On 12/30/2007 8:04 AM, varkey wrote:

[please wquote enough context for your post to stand alone, fixed below]

> Hi,
>
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
>
> Can anyone put some !dea ?
>
> Thanks in advance
>
> Yeah i need to take the difference from the current time only.

With GNU awk:

gawk '{gsub(/:/," ");print systime() - mktime(strftime("%Y %m %d ")$0)}' file

Regards,

Ed.
Ed Morton [ So, 30 Dezember 2007 19:04 ] [ ID #1895971 ]
Linux » comp.unix.shell » Time difference calculation

Vorheriges Thema: Top 10 posters comp.unix.shell
Nächstes Thema: Re: How to setup a simple shell script? "bad interpreter: No suchfile or directorybin/bash"