awk is automatically duplicating some lines. Can someone explain?
0
votes
2
answers
146
views
My data looks like:
A 4 G 1 G 1
C 4 C 2 C 2
T 6 T 5 T 5
A 6 T 2 T 2
C 6 T 2 T 2
T 6 G 2 G 2
I am trying the command:
awk -F " " '$1==$3 {$7=$6; print $0;}
$1==$5 {$7=$4; print $0;}
($1 != $3 && $1 != $5) {$7=$2; print $0}' test.txt
While the data has only 5 lines the output has 7 lines and certain lines are randomly duplicated.
Somehow it happens with only this dataset and not the other datasets that I have.
Can someone please help. I don't understand what is happening
Asked by user563991
(9 rep)
Mar 3, 2023, 03:28 PM
Last activity: Mar 3, 2023, 03:50 PM
Last activity: Mar 3, 2023, 03:50 PM