I am having a file with ~10,000 columns and ~20,000 rows in the following format
Id A_1 A_2 A_3 B_2 B_5 C_1
T1 0 1 1 6 1 0
T2 1 1 1 0 0 1
T3 2 0 3 1 1 5
T4 1 1 1 2 3 1
In the header row, 1st column is the id. From 2nd column onward are the sample name in the following format sampleName_batch#. Now, I want to add all the values for the id's based on the sampleName and have the sampleName and the sum up value in the output. My expected output is
Id A B C
T1 2 7 0
T2 3 0 1
T3 5 2 5
T4 3 5 1
I have came across this answer https://unix.stackexchange.com/questions/569615/combine-columns-in-one-file-by-matching-header but i dont know how to modify the whole header row.
Thanks