If it might be that a very simple terminal printout would suffice, and that you could be satisfied by inverted axes, consider the following:
seq 1000 |
grep -n 11 |
while IFS=: read -r n match
do printf "%0$((n/10))s\n" "$match"
done
The above charts an inverted trend on a 10% scale for every occurrence of the pattern 11 in the output of seq 1000
.
Like this:
11
110
111
112
113
114
115
116
117
118
119
211
311
411
511
611
711
811
911
With dots and occurrence count it could be:
seq 1000 |
grep -n 11 | {
i=0
while IFS=: read -r n match
do printf "%02d%0$((n/10))s\n" "$((i+=1))" .
done; }
...which prints...
01 .
02 .
03 .
04 .
05 .
06 .
07 .
08 .
09 .
10 .
11 .
12 .
13 .
14 .
15 .
16 .
17 .
18 .
19 .
You could get the axes like your example with a lot more work and tput
- you'd need to do the \033[A
escape (or its equivalent as is compatible with your terminal emulator) to move the cursor up a line for each occurrence.
If awk
's printf
supports space-padding like the POSIX-shell printf
does, then you can use it to do the same - and likely far more efficiently as well. I, however, do not know how to use awk
.