I want to sum the values of the rows of my data that have the same ID in the first column. My data looks like
data.txt
Id a b c d e
1 1 2 3 4 5
1 2 3 4 5 6
1 3 4 5 6 7
2 4 5 6 7 8
2 5 6 7 8 9
2 6 7 8 9 10
3 7 8 9 10 11
3 8 9 10 11 12
3 9 10 11 12 13
3 10 11 12 13 14
4 11 12 13 14 15
4 12 13 14 15 16
5 13 14 15 16 17
5 14 15 16 17 18
Required results
out.txt
Id a b c d e
1 6 9 12 15 18
2 15 18 21 24 27
3 34 38 42 46 50
4 23 25 27 29 31
5 27 29 31 33 35
Best Answer
This
GNU awk
script should do the job:Edit:
Here is a version that preserves the original row ordering instead of sorting the ids: