aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-11 00:03:09 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-11 00:03:09 +1300
commit600200443e6f532c14a27c05d72cc7ea41d373f6 (patch)
treee268af7caf5fe1a05e2c04694596ec10a81ab67b
parentHave sec(1df) notice too many fields (diff)
downloaddotfiles-600200443e6f532c14a27c05d72cc7ea41d373f6.tar.gz
dotfiles-600200443e6f532c14a27c05d72cc7ea41d373f6.zip
Abuse FS in sec(1df) for clever zero-stripping
-rw-r--r--bin/sec.awk12
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