I've got a command that outputs a few different lines constantly (a stream), I'd like a live summary of the number of times each line has occurred (with a few seconds latency being acceptable).
for example if my command outputs the following:
apple apple apple apple banana orange banana
I'd like something like:
4 apple 2 banana 1 orange
and for the output to refresh every few seconds.
How might I achieve this? (rereading an entire log file will take too long, it has to be the output of a live pipe)