Skip to content

Commit c3a1f18

Browse files
committed
Add hist util
1 parent b3698eb commit c3a1f18

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

hist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# Reads data from STDIN and draws a frequency histogram. -r assumes
3+
# pre-aggregated data
4+
# Usage: hist [-r] [plot function] [plotchar]
5+
# "plot function" is any valid perl expression, with "x" being the value.
6+
f(){ sort | uniq -c; }
7+
if [ "$1" = '-r' ]; then
8+
f() cat
9+
shift
10+
fi
11+
e="$(printf '%s' "${1:-x}" | perl -pe 's/x/\$F[0]/g;s/\\\$F\[0\]/x/g')"
12+
c="${2:-#}"
13+
f | perl -lane 'print "$F[1]\t$F[0]\t", "'"$c"'"x('"$e"')'

0 commit comments

Comments
 (0)