コマンドの使用数 ランキング

zshのヒストリーから、コマンドの使用ランキングをだす。

ログファイルはこんな感じになっています。

.zsh-history
: 1181927455:0;ls
: 1181927456:0;ll
: 1181927505:0;ls
: 1181927506:0;ll
: 1181927516:0;cd /bin
: 1181927524:0;ls
: 1181927526:0;cd /bin
: 1181927569:0;ls
: 1181927570:0;ll
: 1181927570:0;ls

less .zsh-history | cut -d \; -f 2 |sort|uniq -c |sort -nr|less

結果
1655 ls
504 ll
227 exit
142 cd ..
129 cd
109 /etc/init.d/apache restart
82 sudo -s
58 vi .screenrc
54 ps aux
43 vi rsa.php
43 vi extra/httpd-vhosts.conf
39 screen
35 screen -ls

しっかりと使用回数があたまにつき多い順でソートされています。
ポイントはuniqコマンドの前にsortしなければならないことです。