Implement simple textual barplot
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 23 Dec 2019 22:04:40 +0000 (17:04 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 23 Dec 2019 22:04:40 +0000 (17:04 -0500)
home/bin/barplot [new file with mode: 0755]

diff --git a/home/bin/barplot b/home/bin/barplot
new file mode 100755 (executable)
index 0000000..dce8325
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+set -e
+
+awk '
+    {
+        v = val[NR] = $1
+        key[NR] = $2
+        if (v > max)
+            max = v
+    }
+
+    END {
+        for (i = 1; i <= NR; i++) {
+            printf "%s ", key[i]
+            for (j = 1; j <= (val[i] * 100) / max; j++) {
+                printf "|"
+            }
+            printf "\n"
+        }
+    }' \
+| column -t
This page took 0.024209 seconds and 4 git commands to generate.