Given this list of names and numbers:
Kirilienko:47
James:23
Bryant:24
Durant:35
Griffin:32
How would I find sum the numbers in the second field and print them in an awk script, in the sentence:
print "The total number of these five players is [161]."
I've done a bit of research and saw the general way to sum a column was with awk {sum += $3} END{print sum}. I've tried to implement this in my script, only to return sum = 0.
Set the field separator as
:, and get the sum of the second field. In theENDblock print the sum with desired text:Example: