Popular Posts


Gnome 3

Get your 'Delete' button back!

Fedora 15 + Eclipse = Android SDK

Setup Android SDK with Eclipse on your Fedora 15

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

12 August 2009

Sorting by column using awk

Awk is an powerful command language that allows the user to manipulate files containing columns of data and strings. Awk is extremely useful, both for general operation of Unix commands, and for data reduction (e.g. IRAF).

After using copy and paste method (why I dun think about awk before?) to sort my data, I remember in my Fedora days by using, awk,sed,grep etc.

As you can see, I only want the group of numbers which in red line box. How do I do that? Awk.
awk avaiable straight away from your terminal for Unix or gawk for Win.

Example, in your terminal (I'm using cygwin) :

awk '/Z/ { print $5 } [file name] > output.txt

/Z/ -> Find line only contain Z

print $5 -> Print 5th column

[file name] -> input file without []

> -> extract to. In this case, extract to output.txt

Result,




You can refer here for more example.

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More