Example: print only last and first fields awk '{print $NF " " $1}' grades.txt Example: replace grades with average awk '{print $1 " " ($2+$3)/2}' grades.txt Compute class average on hw1 awk '{x+=$2; i++} END { print x/i}' grades.txt Print Jane's grade for hw1 awk '/Jane/{print $2}' grades.txt Print all records between the lines that match Bob and those that match Jane awk '/Bob/, /Jane/ {print $0}' grades.txt Print records for all people with a grade below 8 on hw1 awk '$2 < 8 {print $0}' grades.txt Examples with different delimiters awk -F " - " ' {print $1 " " ($2+$3)/2}' grades2.txt Print people's logins and locations of their home directories awk -F : '{print $1 " " $6}' /etc/passwd Compute average for all students whose name contains the letter o awk '$1 ~ /o/ {print $1 " " ($2+$3)/2}' grades.txt Compute average for all students whose name starts with J or C awk '$1 ~ /[JC].*/ {print $1 " " ($2+$3)/2}' grades.txt Printing a message before the results awk 'BEGIN {print "Starting:"} $1 ~ /[JC].*/ {print $1 " " ($2+$3)/2}' grades.txt Useless example with using some variables awk 'BEGIN {total=10} {total=total+$2} END {print total}' grades.txt