AWK Programming Language

The awk utility interprets a special-purpose programming language that makes it possible to handle simple data-reformatting jobs with just a few lines of code.

AWK Basic

Awk is a programming language that can handle and manipulate data. Suppose we have the following data file.

datafile.txt
orange 22.5 0
banana 19.5 12
apple 23.0 0
mango 25.0 30
papaya 22.5 25

Print only certain field, first field for instance.

~
awk '{print $1}' datafile.txt

Print the lines (the whole line, $0) with value at third field is greater than 0.

~
awk '$3 > 0 {print $0}' datafile.txt

Do some maths (value at second field is multiplied by value at third field) and print.