$ history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s
",a[i],i}}'|sort -rn|head
174 git
74 ls
67 cd
55 git-p4
29 svn
26 hg
11 sudo
8 mkdir
7 p4
4 ssh
That looks about right
- April 10, 2008
- Posted by: dehora
7 Comments
This seems easier to read (probably less efficient tho - but fast enough is fast enough):
$ history | awk '{ print $2 }' | sort | uniq -c | sort -rn | head
2502 cd
2122 ls
1781 exit
1126 listpodcasts.sh
860 sudo
738 ssh
712 movepodcasts.sh
566 hpodder
543 rm
455 ./getthesiscount
I had to tweak it a little to get newlines:
history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s\n",a[i],i}}'|sort -rn|head
88 cd
53 ls
32 /etc/init.d/networking
27 sudo
24 gedit
23 svn
21 ssh
18 /etc/init.d/apache2
11 vpnc
11 locate
yeah, my connection's a bit flaky, and sudo is probably mostly sudo bash - bad habit
scared that I independently also came up with:
$ history|awk '{print $2}'|sort | uniq -c | sort -rn | head
225 ls
67 cd
66 pwd
53 vi
15 svn
10 make
10 history|awk
8 rm
8 mkdir
7 git
I type ls and pwd a *lot* and without thinking ..
$ history|awk '{a[$2]++} END{for(i in a){printf "\n%5d\t%s ",a[i],i}}'|sort -rn|head
82 c
75 ls
50 cd
32 git
29 ./mgrep
21 date
18 cat
15 rm
13 ruby
12 mate
---
alias c=clear
date must be run from an apple script I use daily
mgrep was a cmdline program I wrote
mate is TextMate, which I'm sure you knew
A friend just pointed out "sort | uniq -c" to me... so I fumbled around and in a minute I came up with exactly what the earlier commenters came up with:
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
I find that to be pretty amazing. This article also sparked an interest in me to learn awk. Much cooler than I thought it was. Thanks.
giorgio@Indy:~$ history | awk '{ print $2 }' | sort | uniq -c | sort -rn | head
2046 vim
449 ./sync-2.3
357 cd
289 ls
159 gcc
123 svn
111 mplayer
108 python
103 sudo
101 ssh
(wow, it seems I write a lot...)
whatever it is, call it "mostUsed() { history ... ; }" i.e. put it in a function!