I am trying to find records in a text file that appear in reverse order then sum the duplicate records that occur. Records I mean as a row. The first two columns will contain identifiers which can be in an order of (A to B) or (B to A). What I would like to do is sum columns 3,4,5 if (columns A,B are equal to B,A). I found an answer for removing records here with awk. However, could find anything on adding them.
remove redundancy in a file based on two fields, using awk
However I would like to add them.
Example data:
g10001.t1 g6838.t1 3 8 4
g6838.t1 g10001.t1 3 5 3
g10001.t1 g964.t1 2 4 2
g964.t1 g10001.t1 1 2 1
g10001.t1 g10604.t1 1 2 1
Desired data:
g10001.t1 g6838.t1 6 13 7
g10001.t1 g964.t1 3 6 3
g10001.t1 g10604.t1 1 2 1