Tips&Tricks

How to get top 10 commands

unix

It’s more like a joke / just for jun task. But it also perfectly shows one of the Unix principle:

Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new “features”.

Actually even two principles;

Write programs to handle text streams, because that is a universal interface.

So this joke is a good demonstration of Unix.

Get top 10 commands which you used:

history \
| awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' \
| sort \
| uniq -c \
| sort -r \
| head