citizen428.blog()

Try to learn something about everything

Most Used Shell Commands

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:

1

1
<span class='line'>history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head</span>

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:

1
2
3
4
5
6
7
8
9
10
11
$ 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 ;) ).

Comments

Copyright © 2016 - Michael Kohl - Powered by Octopress