Jason Welsh wrote: > hrm.. seems like you were missing a } > > sort file | awk '{array[$1] += $2;} END { for (i in array) {print i "\t" > array[i];}}' > Oops. Well, it's not vi, it's webmail, so I couldn't check... <g> Thanks. mark > > regards, > > Jason > > > > On 10/25/2017 01:24 PM, m.roth@xxxxxxxxx wrote: >> Warren Young wrote: >>> On Oct 25, 2017, at 10:02 AM, Mark Haney <mark.haney@xxxxxxxxxxx> >>> wrote: >>>> I have a file with two columns 'email' and 'total' like this: >>>> >>>> me@xxxxxxxxxxx 20 >>>> me@xxxxxxxxxxx 40 >>>> you@xxxxxxxxxx 100 >>>> you@xxxxxxxxxx 30 >>>> >>>> I need to get the total number of messages for each email address. >>> This screams out for associative arrays. (Also called hashes, >>> dictionaries, maps, etc.) >>> >>> That does limit you to CentOS 7+, or maybe 6+, as I recall. CentOS 5 >>> is >>> definitely out, as that ships Bash 3, which lacks this feature. >> <snip> >> Associative arrays? >> >> Awk! Awk! (No, I am not a seagull...) >> >> sort file | awk '{ array[$1] += $2;} END { for (i in array) { print i >> "\t" >> array[i];}' >> >> mark "associative arrays, how do I love thee? Let me tot the >> arrays..." >> >> >> _______________________________________________ >> CentOS mailing list >> CentOS@xxxxxxxxxx >> https://lists.centos.org/mailman/listinfo/centos > > _______________________________________________ > CentOS mailing list > CentOS@xxxxxxxxxx > https://lists.centos.org/mailman/listinfo/centos > _______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx https://lists.centos.org/mailman/listinfo/centos