Contact Me


  • Akshay Java's Facebook profile

Social Media Events

Friends

FriendFeed

Disclaimer

  • Thoughts and comments expressed here are those of the author. Creative Commons License

« Distinguished Speaker: Jiawei Han on "Research Challenges in Data Mining" | Main | LiveBlogging Tools: CoveritLive »

April 24, 2008

Favorite Commandline Hack

One of my favorite commandline hacks is demonstrated by the following example:

history | gawk -F ' ' '{print $2}' | sort | uniq -c | sort -nr | more

What this does is takes a text file (or history of the commands used in our case), chops it to print the right field, sorts and counts the number of times a particular term occurs. For example here are the top commands I have used on this server:

    373    ls
    268    cd
     42    more
     29    ps
     27    rm
     25    du
     24    ./bin/startup.sh
     22    exit
     17    source
     15    emacs
     14    sudo
     13    ssh

This is immensely useful and a quick way to do anything from process a huge file, count the number of times a link occurs, word counting and all sorts of processing that come up frequently in large social media datasets. Its a really easy way to do some mundane tasks without having to write a script or much code for it. So what are your favorite commandline hacks? share the joy! :-)

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/2871784/28460312

Listed below are links to weblogs that reference Favorite Commandline Hack:

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Post a comment

If you have a TypeKey or TypePad account, please Sign In

Google Ads

Ads

Search this blog


  • WWW
    socialmedia.typepad.com

Recent Readers

August 2008

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Please Support