shithub: bin.rc

Download patch

ref: 6a34b0e46ad23af977dc230f885161f8bdc15520
parent: 1bab993af3da2ba2ee9e84d8602c9ae67f7c58d1
author: kvik <kvik@a-b.xyz>
date: Sat Apr 18 19:08:20 EDT 2020

hist: slightly parameterize

These should become command-line parameters.

--- a/bin/hist
+++ b/bin/hist
@@ -5,10 +5,14 @@
 		t = t s
 	return t
 }
-{ x[int($1/10)]++ }
+BEGIN {
+	buckets = 20
+	maxval = 1000
+}
+{ x[int($1/(maxval/buckets))]++ }
 END {
-	for (i = 0; i < 10; i++)
+	for (i = 0; i < buckets; i++)
 		if (x[i] > max) max = x[i]
-	for (i = 0; i < 10; i++)
+	for (i = 0; i < buckets; i++)
 		printf("%-10d - %s\n", x[i], rep("*", x[i]))
 }