Most commonly used shell commands

2014-05-12 1 min read

    I spend a large chunk of time working in the terminal and was curious to see what my most commonly used shell commands were. This also gave me an opportunity to practice writing one liners and learn a bit of awk.

    history | cut -d' ' -f4 | awk '{a[$0]++}END{for(i in a)print i,a[i]}' | sort -k 2 -n -r

    The script is simple - look through my command history, extract the first word, and count the number of times that word appears. I was surprised to see git at the top but it makes sense - I tend to run it as a sequence (git status, git commit, git push) so it leads to an inflated count. The rest make sense - they’re a mix of the standard navigation commands as well as command related to my current projects. Next step is to set up a cron job to track this usage over time and see how it changes.

    CommandFrequency
    git347
    ls103
    python89
    fab70
    cd49
    ssh28
    cat28
    ping23
    emacs22
    stash15
    rm15
    rake15
    pip14
    cdblog14
    pwd12
    jekyll12
    connectec211
    sudo9
    workon7
    wc7
    phantomjs6
    history5
    head5
    c_do5
    brew5
    sh4
    mv4
    make4
    grep4
    sass3
    redis-cli3
    open3
    mkvirtualenv3
    find3
    celery3
    source2
    sed2
    redis-server2
    mkdir2
    echo2
    dig2
    cp2