troubleshooting Question

sort/merge and total matching key records using awk.

Avatar of henrywilson
henrywilsonFlag for United Kingdom of Great Britain and Northern Ireland asked on
Shell Scripting
4 Comments1 Solution850 ViewsLast Modified:
I have two (or more) files which have the same structure

i.e.
file1
01,ann,2,3,6,.......  
01,tim,9,8,7,.......
01,max,1,1,1,.....
etc

file2
01,ann,6,7,8,.........
01,tim,1,2,3,.......
01,jenny,2,2,2,....
etc

I want to merge these files into one but only have one record per person, with totalled values.

outfile
01,ann,8,10,14,.......
01,jenny,2,2,2,....
01,max,1,1,1,....
01,tim,10,10,10,.......
etc

There are over 2000 people on each flle and 70 variables to be totalled for each.
It is fairly straightforward to sort /merge the files and I can produce a an overall sum total of each column, but how do I just summarise multiple records for each person ?.

Needs to be achieved using awk.

Any help greatly appreciated.





Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros