From 600200443e6f532c14a27c05d72cc7ea41d373f6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 11 Dec 2016 00:03:09 +1300 Subject: Abuse FS in sec(1df) for clever zero-stripping --- bin/sec.awk | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bin/sec.awk b/bin/sec.awk index 45befd76..872a0bcf 100644 --- a/bin/sec.awk +++ b/bin/sec.awk @@ -1,9 +1,7 @@ # Convert [[[hh:]mm:]ss] timestamps to seconds -# Separator is : -BEGIN { - FS = ":" -} +# Separator is :, strip out leading zeroes +BEGIN { FS = ":0*" } # If no fields, too many fields, or illegal characters, warn, skip line, accrue # errors @@ -13,12 +11,6 @@ BEGIN { next } -# Strip leading zeroes to stop awk trying to be octal -{ - for (i = 1; i <= NF; i++) - sub(/^0*/, "", $i) -} - # Match hh:mm:ss NF == 3 { printf "%u\n", $1 * 3600 + $2 * 60 + $3 -- cgit v1.2.3