tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: "Carl Christopher Bavington @ Langley" <Carl.Bavington@ntl.com>
Subject: SUMMARY: Command or shell script to add times?.
Date: Thu, 22 May 2003 14:28:52 +0100	[thread overview]
Message-ID: <D38E587F63FBD411811900508B134C4C04239F60@NTWI-WI0-SE01> (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



                 reply	other threads:[~2003-05-22 13:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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