Popular Posts


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.

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More