[awk] Get the last field of each line

Created on November 30, 2026

NF is the number of fields on the current line, so $NF is the value of its last field. Start with a file named fruits.txt.

apple red 120
banana yellow 80
grape purple 300

Print the last field on each line.

awk '{print $NF}' fruits.txt

Output

120
80
300
awk Shell command