for loops

You can use for loops to iterate over values when using AWK like this:

$ awk '{
total = 0
for (var = 1; var < 4; var++)
{
total += $var
}
mean = total / 3
print "Mean value:",mean
}' myfile  

We achieved the same result but using the for loop this time.