I'm looking for an existing Linux command-line tools that can accomplish the following:
Consider there is an input stream
/dev/inputstream
which spews an infinite stream of data that looks like this:
A
A
B
A
C
Z
A
.
.
.
**NOTE:** (Each line is one character from the alphabet).
The tool is used in the following fashion:
cat /dev/inputstream | tool
The output of the tool should be like the one from "top" command. It should be a continuously updated list of top N frequently occurring items.
Eg:
A -- 10 times
B -- 8 times
Z -- 7 times
C -- 2 times
D -- 1 time
If the stream were not infinite I could have accomplished this using sort
and uniq
.
Asked by Prashanth Ellina
(199 rep)
May 15, 2014, 06:18 PM
Last activity: Mar 5, 2025, 06:33 AM
Last activity: Mar 5, 2025, 06:33 AM