2
Hello I need to do an awk if command using 4 different conditions together, example of my input just for a few lines (I have an input with thousands of lines)
chr17_30 1
chr1_72 0
chr1_46 2
chr1_47 -1
chr1_48 1
Desirable output
chr17_30 1 AB
chr1_72 0 AA
chr1_46 2 BB
chr1_47 -1 NN
chr1_48 1 AB
How do I do this? Only able to do one condition using awk if. It can be another command too.
thank you Clarissa
how do you determine the added column? where the (AB,AA,...) come from? What did you try?
– JJoao
hi @jjoao this encoding is pre-established for my genetic data. Code 1 means my pet is AB, 2 is BB, -1 is given lost (NN) and 0 is AA. What I did was use the command: cat input.txt | awk 'BEGIN{FS=" t"}; BEGIN{OFS=" t"}; {if ($2==1) {print $0,"AB"} Else{print $0, " t"}}' | awk 'BEGIN{FS=" t"}; BEGIN{OFS=" t"}; {if ($2=0) {print $0,"AA"} Else{print $0, " t"}}' | head But in this case the encoding is in separate columns and I want everything in the same column.
– Alex