Using awk to sum the values of a column, based on the values of another column
108
votes
6
answers
431802
views
I am trying to sum certain numbers in a column using
awk
. I would like to sum just column 3 of the "smiths" to get a total of 212. I can sum the whole column using awk
but not just the "smiths". I have:
awk 'BEGIN {FS = "|"} ; {sum+=$3} END {print sum}' filename.txt
Also I am using putty. Thank you for any help.
smiths|Login|2
olivert|Login|10
denniss|Payroll|100
smiths|Time|200
smiths|Logout|10
Asked by jake
(1225 rep)
Nov 14, 2015, 04:56 AM
Last activity: Jul 14, 2025, 05:03 AM
Last activity: Jul 14, 2025, 05:03 AM