tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: Command or shell script to add times?.
@ 2003-05-22 13:28 Carl Christopher Bavington @ Langley
  0 siblings, 0 replies; only message in thread
From: Carl Christopher Bavington @ Langley @ 2003-05-22 13:28 UTC (permalink / raw)


Thanks to Dr Tim Cutts.

I did it in ksh instead, adding 40 if gt than 59 etc, etc.
But Dr Tim suggested.

Fairly easy to do with an in-line perl script:

#!/bin/sh

addtime() {
  perl -e 'use integer;
    my ($h, $m, $s) = ($ARGV[0] =~ m/\G(\d\d)/g);
    if (($s += $ARGV[1]) >= 60) {
      $m += ($s/60); $s %= 60;
      if ($m >= 60) { $h += ($m/60); $m %= 60; }
      $h %= 24;
    }
    printf "%02d%02d%02d\n", $h,$m,$s;' $1 $2
}

addtime 235859 5


The contents of this email and any attachments are sent for the personal attention
of the addressee(s) only and may be confidential.  If you are not the intended
addressee, any use, disclosure or copying of this email and any attachments is
unauthorised - please notify the sender by return and delete the message.  Any
representations or commitments expressed in this email are subject to contract.
  
ntl Group Limited



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-22 13:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-22 13:28 SUMMARY: Command or shell script to add times? Carl Christopher Bavington @ Langley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox