## difftime by Chris F.A. Johnson ## Created Fri Dec 29 03:09:25 EST 2006 ## Copyright 2006 Chris F.A. Johnson ## This script is released under the terms of ## the GNU General Public Licence, Version 2 version=0.2 if [ $# -ne 2 ] then cat <<-EOF difftime - calculate sub-second difference between two times USAGE: difftime MM:SS.Frac MM:SS.Frac EOF exit fi awk -v begin="$1" -v end="$2" 'BEGIN { split ( begin, t1, ":" ) split ( end, t2, ":" ) d2 = 60 * t2[1] + t2[2] d1 = 60 * t1[1] + t1[2] diff = d2 - d1 minutes = int(diff / 60) seconds = int(diff) % 60 split ( diff, d, "." ) printf "%1d:%02d.%d\n", minutes, seconds, d[2] exit }'