7

I have a tab separated file like this:

1       10502   C       T  
1       10506   C       T  
1       10567   G       A 
...

And I'm trying to print out all lines where column 3 != column 4, excluding the cases where column 3 = C and column 4 = T.

I tried

awk '{
if (($3 == $4) || ($3 == C && $4 == T) )
        next ;
else
        print $0; }'

but I'm not sure what's going wrong...

2 Answers 2

10

just fix your codes:

awk '($3 != $4) && !($3=="C" && $4=="T")' file
0
-1

this one-liner should work for your file:

awk '($3==$4)||($3 =="C"&&$4=="T"){next}1' input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.