From: Siraaj Khandkar Date: Mon, 23 Dec 2019 22:04:40 +0000 (-0500) Subject: Implement simple textual barplot X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=c17be636ca003e34172250a5f494f65b901fa27e;p=khome.git Implement simple textual 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