Most used shell commands

25 05 2009

I recently found a bash snippet which creates a list of the commands in your .bash_history file and how many times you invoked them:

history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head

Although there was no real point in doing so, I felt the need to write a short Ruby script to do the same:

Here’s the output on my MacBook:

$ command_stats | head
time: 75
cd: 68
ls: 66
git: 35
cat: 32
irb: 20
awk: 17
ruby: 15
scala: 15
vim: 12

If you are surprised by how many times (no pun intended) I called time, it’s just because I was benchmarking Project Euler solutions in several languages, everything else is quite regular (and suggests I don’t use the Finder much ;-) ).



Trackbacks


No Trackbacks

Comments

Display comments as (Linear | Threaded)
28 05 2009
#1 berg (Reply)

huhu, and this is for the lazy sysop :-)
awk ‘{print $1}’ ~/.bash_history|sort|uniq -c|sort -nr|head
my top 3 are:
87 ls
68 vi
35 screen

29 05 2009
#2 colo (Reply)

Since my screen sessions take place on remote hosts, mostly, that’s what I get:

colo@zealot ~ $ history | awk ‘{a[$2]++ } END{for(i in a){print a[i] " " i}}’|sort -rn|head
165 ssh
100 ls
90 sudo
57 kvm_run
56 cd
54 vim
40 man
21 cat
19 xrandr
19 upload


Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Textile-formatting allowed

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


Standard emoticons like :-) and ;-) are converted to images.