# What’s in my history?
在 一宁的 blog 上看到这么好玩的命令:
$history | awk '{a[$2]++} END{for(i in a){printf %5d\t%s\n,a[i],i}}'|sort -rn|head
82 ls
64 cd
44 sudo
42 vim
37 svn
25 lftp
22 ./test.sh
17 memcached-tool.pl
11 ping
11 gvim
下面是改进版,可以加入百分比统计:
$history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] CMD[a]/count*100 % a;}' | grep -v ./ | column -c3 -s -t | sort -nr | nl | head -n10
1 82 16.4% ls
2 64 12.8% cd
3 44 8.8% sudo
4 42 8.4% vim
5 37 7.4% svn
6 25 5% lftp
7 17 3.4% memcached-tool.pl
8 11 2.2% ping
9 11 2.2% gvim
10 10 2% exit
是不是很有意思,快点回复让我看看你的吧。:)
April 14th, 2008 at 22:24
1 112 22.4% svn
2 110 22% cd
3 104 20.8% ls
4 34 6.8% exit
5 28 5.6% sudo
6 26 5.2% vi
7 23 4.6% ssh
8 16 3.2% ping
9 7 1.4% whois
10 6 1.2% open
干!一定要带中文才能回复阿!
April 15th, 2008 at 23:12
1 66 13.2% cd
2 52 10.4% ls
3 51 10.2% vi
4 49 9.8% ll
5 45 9% enmv.php
6 32 6.4% sudo
7 26 5.2% svn
8 21 4.2% tail
9 16 3.2% screen
10 16 3.2% df
听说留言要有中文。。。
April 16th, 2008 at 09:49
楼上的……
October 17th, 2008 at 10:29
1 120 24% ls
2 92 18.4% cd
3 84 16.8% sudo
4 16 3.2% vi
5 15 3% emerge
6 13 2.6% find
7 12 2.4% rm
8 12 2.4% ps
9 12 2.4% ping
10 12 2.4% make
Your comment message must contain at least one chinese word! 汗