Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printing lines where certain columns do not match, with awk

Tags:

matching

awk

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...

like image 648
user2232814 Avatar asked Apr 26 '13 21:04

user2232814


1 Answers

just fix your codes:

awk '($3 != $4) && !($3=="C" && $4=="T")' file
like image 147
Kent Avatar answered Oct 19 '22 10:10

Kent