I have the following file:
452 0/0 10 30 40
460 0/1 0 40 40
500 0/0 5 35 40
600 0/1 15 25 40
800 1/1 40 0 40
The real file contains millions of lines. If the second field is 0/0, I print the 3rd and 5th columns. If the second field is 1/1, I print the 4th and 5th columns. Using this command:
awk 'BEGIN{OFS="\t"}{ if($6=="0/0") {print $1, $2, $3, $5} else if($6=="1/1") {print $1, $2, $4, $5}}' file
The problem is that when the second field is 0/1. I want to randomly choose 0 or 1, if chosen 0, print 3rd and 5th columns and if chosen 1, print 4th and 5th columns.
Is there a way to randomly choose 0 or 1 every time there is a 0/1? The code could be in awk, bash or python.
Aucun commentaire:
Enregistrer un commentaire