Home | About the author | Resume | << Rule Engine Stress Testing | Redefining web applications with AJAX, Servlets and JSON >>
SMS Bundle - Mobile Marketing Solutions
SMS Bundle is an Australian-based service for sending marketing SMS and MMS

You gotta love Linux

Last Friday as I was working, I was asked to get some information from the application logs for a particular period of time. I needed to extract some data and count the results. The given period was last twelve months.

Luckily I am working with Linux, so I opened a shell session and typed the following after doing some research on the Internet:
grep -B4 "String1" *.log | grep "String2" | cut -d\   -f2 | sort -u | wc -l
Basically what the command does is:
  1. In all files with extension log , grab 4 lines before occurrence of "String1" and pass the outcome result to the next command
  2. Find occurrence of "String2" and pass the outcome result to the next command
  3. Split by SPACE delimiter and grab the second field and pass the outcome result to the next command
  4. Sort in unique manner and pass the outcome result to the next command
  5. Count the results and output
Simple and efficient. The whole process took only few seconds.

I do not think I could have done this so easily if I would be working on Win platform...

You gotta' love Linux! ;)
Categories : linux
Technorati Tags : , ,
Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!

Related Posts
There are no related posts for this blog entry




If you like this post, then consider subscribing to the full feed RSS.




Add a comment    Send a TrackBack