In reference to this question regarding column to row transposition using awk I am baffled as to why Ive been unable to display the last column in a row and I suspect the CR from the end of the row is being added to the array to print.
As this appears to be the case as per the linked question on DOS endings how do I remove the CR from the last field in the context of the awk script presently being used (without running something like dos2unix):
{ 
         if (!keys[$3]++) { b[++c] = $3; row1 = row1 OFS $3; row2 = row2 OFS $4 }
         line = groups[$1][$3];
         groups[$1][$3] = (line == ""? $6$7: line OFS $6$7) 
     }
     END{ 
         print row1 ORS row2; 
         for (i in groups) {
             r = i; 
             for (j in b) r = r OFS groups[i][b[j]];
             print r 
         } 
     }
The column with suspected CR is $7, eg
22405   XRJ27   IL17C       rs4673      C______2038_20  N   N
22405   XRJ27   CRP     rs2794520   C____177486_10  T   T
22405   XRJ27   G6PC2       rs560887    C____323082_10  C   C
22405   XRJ27   TCN2        rs1801198   C____325467_10  G   G
22405   XRJ27   SLC30A8     rs13266634  C____357888_10  C   C
22405   XRJ27   COL5A1      rs12722     C____370252_20  C   C
22405   XRJ27   LEPR        rs1137100   C____518168_20  A   G
