Count occurrences per key awk
Frequency count of the first field (e.g. IP addresses)
awk '{count[$1]++} END {for (k in count) print count[k], k}' access.log | sort -rn
more awk
all 15 commands →
Print last field
awk '{print $NF}' file.txt
Multi-condition filter
awk '$2 > 500 && $5 == "POST"' access.log
Reformat output
awk '{printf "%-20s %5d\n", $1, $2}' data.txt
Run awk script from file
awk -f transform.awk input.txt
In-place-style transform with awk
awk '{gsub(/foo/, "bar"); print}' input.txt > tmp && mv tmp input.txt