aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-12-13 01:42:42 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-12-13 01:42:42 +0100
commitb1e14c8893656a01b62a4967cb6102ce3e9015b6 (patch)
treec8945c7170048eeb23d497f489bdea3e0c8eed02
parentbfa1b3a0783c6f56996c23bc6662ef597c405057 (diff)
downloadtyp-b1e14c8893656a01b62a4967cb6102ce3e9015b6.tar.gz
Add 'avg' tool
avg calculates averages for multiple typ results stored in separate files.
-rwxr-xr-xavg15
1 files changed, 15 insertions, 0 deletions
diff --git a/avg b/avg
new file mode 100755
index 0000000..7cfc6fe
--- /dev/null
+++ b/avg
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# avg -- print averages for multiple typ result files
+
+awk '
+ {
+ v[FNR] += $1
+ $1 = ""
+ sub(/^ /, "", $0)
+ t[FNR] = $0
+ }
+ END {
+ for (i = 1; i<=5; i++)
+ printf("%.4f\t%s\n", v[i] / (ARGC-1), t[i])
+ }' "$@"