mark@atlantis:~% uname -a
Linux atlantis 2.6.23.9 #1 SMP Sun Dec 2 22:09:17 EST 2007 x86_64 GNU/Linux
mark@atlantis:~% history -1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
181 cd
167 ls
103 sudo
75 rm
42 lsdvd
40 fp
39 mv
38 ll
37 cat
24 mkdir
And root:
atlantis:~# history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
25 mount
20 aptitude
15 cd
11 ls
5 iwconfig
5 exit
5 dpkg
5 df
4 module-assistant
4 cat
Notes:
(I’ve seen this meme sweep through Planet Intertwingly like a bad rash, but Ben’s post is what finally prompted me to participate. In proper meme fashion, I tag Joe and Tim to go next.)
§
[~]$ cat .zsh_history | awk \’{a[$1]++}END{for(i in a){print a[i] \” \” i}}\’ | sort -rn | head
892 python
424 vi
400 cd
380 less
372 sudo
360 exit
230 ls
203 git
137 man
136 pydoc
This is technically not the command you used, but history -1000 didn\’t work that well on my zsh, for some reason. You\’d _never_ guess it from these results, but I\’m a Python programmer…
I think WordPress may have screwed up the quotes in the latter part of the awk statement?
history -1000 gives me an error.
here’s what i had to do to make it work in bash:
history 1000 | awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head
i sadly can’t take part in this meme, since i symlink my ~/.bash_history to /dev/null and have a `history -c` line in my .bash_logout.
i almost wish i didn’t now =)
awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’
Isn’t “awk ‘{print $2} |sort |uniq -c”, besides being easier to type, much clearer? I suppose we may not be going for clear here…
Atlantis is the hostname for my linux box as well.
$ history | awk ‘{print $2}’ | sort | uniq -c | sort -rn | head
245 perl
227 cd
209 ls
161 make
80 perldoc
60 bb
41 sudo
39 release
37 l
35 svn
Some notes:
bb is more alias for invoking bbedit from the command line
release is my software release automation program (found in the Perl module Module::Release)
l is a shortcut for logging out of the session
Looking through .bash_history instead gives a different picture.
$ cat ~/.bash_history | awk ‘{print $1}’ | sort | uniq -c | sort -rn | head
145 perl
117 cd
96 ls
47 git
42 sudo
33 make
33 bb
27 perldoc
21 hm
17 ./configure
97 ls
82 cd
46 mplayer
42 make
33 sudo
30 ./driver
20 vim
15 lame
12 ./test.sh
12 gedit
— SFX ![]()
I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)
§
© 2001–9 Mark Pilgrim