Print last field awk
NF holds the number of fields; $NF is the last field
awk '{print $NF}' file.txt
more awk
all 15 commands →
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
Process CSV with quotes (gawk)
gawk -v FPAT='([^,]+)|("[^"]+")' '{print $2}' data.csv