From c17be636ca003e34172250a5f494f65b901fa27e Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 23 Dec 2019 17:04:40 -0500 Subject: [PATCH] Implement simple textual barplot --- home/bin/barplot | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 home/bin/barplot diff --git a/home/bin/barplot b/home/bin/barplot new file mode 100755 index 0000000..dce8325 --- /dev/null +++ b/home/bin/barplot @@ -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 -- 2.20.1