Linux.com

awk - still fastest for simple stuff

Posted by: Administrator on January 17, 2006 04:45 PM
As soon as I need something more than a few lines long, I use perl or ruby, but for simple processing of data files (e.g. columns of numbers), awk is great:

awk '{print 100.0*$2/$3 }' datafile

Or, how about a little script (summ) to sum the Nth column:

awk '{summ+=$N}{print summ}' N=$1 $2

which is run with e.g. summ 3 datafile.

#

Return to CLI Magic: Learn to talk awk