Command Line King Fu


Command Line King Fu

John Romano
Vice President, Senior Creative Technologist

08.10.2010
Comment: 1
In: Interactive

I needed to go through a couple thousand URLs and pull the TITLE tag for each page. I knew that doing it by hand would be insane, so I stopped by the desk of Mike Artis, our systems administrator and explained what I needed.

Mike thought about it and said "Yea, I could do that."

I asked "How long do you think it would take?"

He said, "About a minute." I thought he was joking so I said thanks and walked away. 

He then emailed me a command to put in my terminal (that's that scary window that allows you to access your system using typed commands). Working in the terminal is kind of like popping the hood of an old car and revving the engine by hand. I made a list of URLs and saved them in a TXT file. Opened my terminal and copied and pasted this:

cat urls.txt | while read url; do title=`perl -MLWP::Simple -e "getprint \"$url\";" | tr '\n' ' ' | awk -F"<title>" '{ print $2 }' | awk -F"</title>" '{ print $1 }' | sed -e 's/^[ \t]*//'`; echo "$url - $title"; done

Magic ensued. Out came a list of title tags and the URL of each. Amazing. And what is more is that it took him a minute and a half

I shouldn't be telling you this though. Sys admins make it their job to tell you that requests will take two weeks when they take five minutes. But that was some serious command line King Fu and the man deserves some props.

The point is that there are power users and there are people like Mike. People who can do things on the command line waaaaay faster than you or I can do in the GUI. People who understand regex, command lines and SSH. These are the people who make things work and keep the machine running. They are necessary so that the rest of us can do our work. And I'm thankful that they are around.

Read more posts by John Romano.


Comments

  • Mike Artis   5:44p.m. 08.10.2010

    The beauty of the command line in a *nix system is the amount of control you have over your environment. In a short amount of time, I created the mess you see above. Hey, it's ugly, but it works.

    While Sys admins do aim to lower expectations, so as not to disappoint, we also take pride in doing as much as we can with as little "actual work" as possible.

    Thanks for the kind words John, I am glad I could help!

Leave a Comment

  • Please confirm your humanity: *

  • * required fields