#This runs before awk starts BEGIN{ total=0; evens = 0; odds = 0; counter=1; } #This is the loop that runs on each line of the file { total=total+$1; counter = counter + 1; if($1 % 2 == 0){ evens=evens+$1; } else{ odds=odds+$1; } } #This runs after every line in the file has been processed. END{ print "evens = ", evens; print "odds = ", odds; print "total = ", total; print "average = ", total/counter; }