Most used commands

pravi@savannah:~$ history|awk ‘{print $2}’|awk ‘BEGIN {FS=”|”} {print $1}’|sort|uniq -c|sort -r|head -10
9 qemu
91 cd
8 free
8 du
87 ls
7 export
7 cat
6 ssh
6 pdftohtml
5 man

Thanks Karthik for that tip.

2 Responses to “Most used commands”


  1. 1 Das

    The above script doesn’t give the “most used” commands – as you can see 9 appears above 91.

    A slight modification does the trick:
    $ history | awk ‘{print $2}’ | awk ‘BEGIN {FS=”|”} {print $1}’ | sort | uniq -c | sort -rg | head -10

    i.e. instead of sort -r, use sort -rg which does a numeric sort.
    –Das

  2. 2 Praveen A

    Das,
    Thanks a lot for the tip.

Leave a Reply