I have 2 files that looks like this:
file1
aaa 5
bbb 2
ccc 9
ddd 46
eee 89
fff 56
file 2
aaa 54
bbb 8
ccc 16
ddd 4
eee 66
fff 9
I would like to have the sum of specific columns
(for example sum of aaa in both files
and sum of ccc + sum of ddd
and sum of bbb + sum of eee + sum of fff)
Is there a simple way to do so with awk for example?
If you simply want the sums, this can be done in pure bash (using associative arrays here, so bash 4 is required):