Here are some values where I need to change :
if first column is 2 => 1
if first column is 8 => 2
if first column is 16 => 3
CHR SNP BP A1 TEST NMISS BETA STAT P
2 rs10173732 31404 A ADD 2607 -0.02162 -1.552 0.1207
2 rs10173732 31404 A COV1 2607 0.2659 24.15 1.849e-116
2 rs11684864 2547285 G ADD 2596 -0.009581 -0.6387 0.5231
2 rs11684864 2547285 G COV1 2596 0.2672 24.18 1.212e-116
2 rs11684864 2547285 G COV2 2596 0.004941 9.564 2.548e-21
8 rs3826201 88651817 T COV3 2576 -0.0186 -15.7 4.335e-53
16 rs8047319 88684276 C ADD 2538 0.01115 1.271 0.204
16 rs8047319 88684276 C COV1 2538 0.2632 23.73 1.402e-112
16 rs8047319 88684276 C COV2 2538 0.005039 9.715 6.276e-22
16 rs8047319 88684276 C COV3 2538 -0.01891 -15.9 2.583e-54
However this command is not convenient, as it changes indentation and the line with the 8 doesn't seem to appreciate :
awk '{ if ( $1 == 2 ) { $1 = 1 } else if ( $1 == 8 ) { $1 == 2 } else if ( $1 == 16 ) { $1 = 3 }; print}' TEST > TESTnew
output :
CHR SNP BP A1 TEST NMISS BETA STAT P
1 rs10173732 31404 A ADD 2607 -0.02162 -1.552 0.1207
1 rs10173732 31404 A COV1 2607 0.2659 24.15 1.849e-116
1 rs11684864 2547285 G ADD 2596 -0.009581 -0.6387 0.5231
1 rs11684864 2547285 G COV1 2596 0.2672 24.18 1.212e-116
1 rs11684864 2547285 G COV2 2596 0.004941 9.564 2.548e-21
8 rs3826201 88651817 T COV3 2576 -0.0186 -15.7 4.335e-53
3 rs8047319 88684276 C ADD 2538 0.01115 1.271 0.204
3 rs8047319 88684276 C COV1 2538 0.2632 23.73 1.402e-112
3 rs8047319 88684276 C COV2 2538 0.005039 9.715 6.276e-22
3 rs8047319 88684276 C COV3 2538 -0.01891 -15.9 2.583e-54
How would you right something more universal (meaning it works even if indentation for a particular line is different) and that doesn't change indentation from the original file?