I have a table like this
ZRSR2_10A_F_P5,18,chrX,15822707,15822993,287,chrX
ZRSR2_10B_F_P5,18,chrX,15822876,15823101,226,chrX
ZRSR2_10C_F_02_P5,22,chrX,15823055,15823310,256,chrX
and I need this
ZRSR2_10A_F_P5,18,chrX,15822707,15822993,287,chrX,15822707,15822725
ZRSR2_10B_F_P5,18,chrX,15822876,15823101,226,chrX,15822876,15822894
ZRSR2_10C_F_02_P5,22,chrX,15823055,15823310,256,chrX,15823055,15823077
I am trying this
awk -F, -v OFS=, '{print $0,$4,$4+$2}'
But I am getting this
,15822707,15822725chrX,15822707,15822993,287,chrX
,15822876,15822894chrX,15822876,15823101,226,chrX
,15823055,1582307722,chrX,15823055,15823310,256,chrX
Why am I getting these results? I thought that -F,: Set the input field separator to a comma. -v OFS=,: Set the output field separator to a comma. {print $0,$4,$4+$2}: Print the entire original line ($0), followed by the value in column 4, and then the sum of column 4 and column 2.