diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-11 00:03:09 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-11 00:03:09 +1300 |
commit | 600200443e6f532c14a27c05d72cc7ea41d373f6 (patch) | |
tree | e268af7caf5fe1a05e2c04694596ec10a81ab67b /bin/sec.awk | |
parent | Have sec(1df) notice too many fields (diff) | |
download | dotfiles-600200443e6f532c14a27c05d72cc7ea41d373f6.tar.gz dotfiles-600200443e6f532c14a27c05d72cc7ea41d373f6.zip |
Abuse FS in sec(1df) for clever zero-stripping
Diffstat (limited to 'bin/sec.awk')
-rw-r--r-- | bin/sec.awk | 12 |
1 files 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 |