Print decimals to 2 places
echo “2.3 4.56789″ | awk ‘{printf “%.2f %.2f\n”, $1, $2}’

To avoid repetition

awk ‘!x[$0]++’ file.txt

To sum up a field

awk ‘{ sum+=$1} END {print sum}’

To Print  Columns 1 and 8 and with selective rows(1 till 3) 

awk ‘ NR==1 || FNR < 4 { print $1 ” ” $8 }’

Advertisements