Print last field
NF holds the number of fields; $NF is the last field
awk '{print $NF}' file.txt
- tool
- awk15 commands
More awk commands
-
awk '$2 > 500 && $5 == "POST"' access.logPrint lines where field 2 > 500 AND field 5 is POST
-
awk '{printf "%-20s %5d\n", $1, $2}' data.txtAligned printf formatting with fixed column widths
-
awk -f transform.awk input.txtLoad awk program from an external script file
-
awk '{gsub(/foo/, "bar"); print}' input.txt > tmp && mv tmp input.txtGlobal substitution and write back to same file
-
gawk -v FPAT='([^,]+)|("[^"]+")' '{print $2}' data.csvParse quoted CSV fields correctly with FPAT in gawk