About Me

I'm a Software Engineer by trade but like to consider myself an all around geek.  This blog is a place where you'll find my thoughts on a number of different things I'm passionate about.  More often than not though that list tends to include: Technology, Social Media and the Web in general, Geek Culture (TV/Movies/SciFi), Space Exploration, Music/A Cappella.

(Any opinions, etc. expressed here are purely my own.)

Presence
Subscribe
« "New Adventures" for Hubble and Manned Spaceflight | Main | STS-125 one for the History Books »
Sunday
May172009

Dir, cls, and some Python

Oookay so for all you kids born say post-1995 who don't know what a command prompt is go to Start -> Run and type 'cmd', this is known as the Command Prompt. Once upon a time your computer would boot into the DOS operating system and all you'd have is a command prompt. The command prompt interface has also long formed the basis of the interface for the UNIX operating system as well. One thing having to deal with a command prompt where you had to type a lot of commands to get anything done did for you was you learned to type and you learned to do it pretty quickly if you didn't want to spend about three hours changing directories.

Somewhere in the ancient history of operating systems probably DOS 5.5 or so I picked up the habit of repeatedly typing dir <enter> cls <enter> in rapid succession I guess to just dissipate boredom or try to figure out what I was doing next. I once again found myself with some energy to dissipate and away it was to the terminal in OSX where I setup the appropriate command aliases and began some rapid fire dir/cls. Eventually it occurred to me that I should build a Python script to calculate the "success rate" of said geekiness and utter insanity. Yes I am apparently that big a dork, and perhaps an even bigger one for blogging about it in detail.

What I came up with was a Python script that isn't perfect but kept me busy for a while tonight with nothing better to do I guess. Here's how the process works in a nutshell:

  1. Issue history -c (with a bash shell to clear the history buffer)
  2. Do a bunch of dirs and clses in rapid succession like some kind of freak.
  3. history > dircls (creates a text file with the command history buffer in it)
  4. python dircls.py dircls (my script)

The script will the look through the file for 'dir' and if 'cls' is directly after it then this counts as a success. Simple enough eh? So yeah feel free to let me know how big a dork I am, although if you made it this far well then I'm in pretty good company it would seem. Back to the terminal I go, command-line geeks represent!

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>