length > 80
{ $2 = log($2); print }
{ sum += $1}
END { print sum, sum/NR }
pattern {action}
pattern {action}
...
awk 'program' [ file1 file2 ...]
awk -f progfile [ file1 file2 ... ]
for each file
for each input line
for each pattern
if pattern matches input line
do the action
array subscripts can have any value, not just integers
canonical example: adding up name-value pairs
input:
pizza 200
beer 100
pizza 500
beer 50
output:
pizza 700
beer 150
program
{ amount[$1] += $2 }
END { for (name in amount)
print name,amount[name] | "sort -k1 -nr"
}