#!/bin/sh
#
# /usr/local/bin/timer
#
# copy into other scripts
# or export BEGIN and END from other scripts
#
# Example:
# #!/bin/bash
# BEGIN=$SECONDS
# export BEGIN
#
# < your script >
#
# END=$SECONDS
# export END
# timer
#
# NOTE -- For BEGIN and END to contain relevant data
# the parent script must have the variable $SECONDS
# available...ie. BASH or KSH scripts
TIME=`expr $END - $BEGIN`
HRS=`expr $TIME / 3600`
MIN=`expr $TIME % 3600 / 60`
SEC=`expr $TIME % 3600 % 60`
#printf 'Elapsed time: %.2d:%.2d:%.2d\n' $HRS $MIN $SEC
printf '%.2d:%.2d:%.2d' $HRS $MIN $SEC