Command line statistics

Well, I’m planning to write here more frequently. For now, I’ll be concentrating on sharing small-ish nuggets of information, instead of trying to write an essay-style post.

This post is about fun little statistics I have gleaned by by zsh history file. Note: my history file contains the last 3000 or so commands I had executed.

Lets begin with trying to find out which version control systems I use most frequently:

$ history | grep 'git ' | wc -l
$ history | grep 'hg '  | wc -l
$ history | grep 'svn ' | wc -l

Mercurial seems to be in the lead right now. Hurrah for distributed version control! We use svn for some projects at work, hg for others. No git, because many of the guys are on Windows.

For my own stuff, I end up using either git or hg, depending on my mood. Don’t really have a preference one way or the other.

Videos & stuff:

$ history | grep 'yd '  | uniq | wc -l
$ history | grep 'vlc ' | uniq | wc -l

yd is my alias for the awesome youtube-dl script that allows me to watch the video in question offline (I hate getting interrupted with a ‘loading’ message when watching anything interesting). It is a resume-able command, so I put in a uniq in the filter chain to just count distinct videos.

grep vs. ack:

history | grep 'grep ' | wc -l
history | grep 'ack '  | wc -l

ack is something better than grep (command name is 25% fewer characters to type!), for code-related stuff anyway. I still end up using grep for piping & stuff, but all the commands above can be re-written by just replacing the grep with an ack.

OK, that’s it for today. Any of you want to share something?

Comments (4)

  1. Andy Lester wrote::

    ack pipes just fine. In fact, you could use "history | ack -w grep | wc -l" in your examples up there.

    Thursday, May 5, 2011 at 1:11 #
  2. Nice to have you back! Now I will read the post and try to understand :-)

    Thursday, May 5, 2011 at 9:37 #
  3. Ankit Solanki wrote::

    @Andy I know, ack works just as well as grep in my examples. I'm just too used to using grep for such situations thoug… in my mind, grep is for pipes, ack is for directories :)

    Thursday, May 5, 2011 at 15:00 #
  4. sumeet pareek wrote::

    I just did a 2 min test run of this and loved it! Great work! Pat on the back and a tip of my hat to you :)

    Monday, May 16, 2011 at 12:18 #