Ale
Ale

Reputation: 41

Eliminate lines based on values in multiple columns

I'm trying to remove rows from a big table but conditioned that one column has one value and another column has other values.

So far I've been trying this but I guess I'm not combining the awk properly..

awk '$11 !="1"'| awk '$20==2 || $20==3' infile.txt >out.txt

The code is probably too simple but should work anyways..or not?

Thanks

edit:

This is what the table looks like

    5306083 TGATCAATCTCATAAC[A/C]AAAAAAAAA  consensus_24    211 1   species 0   0   0   T   0   7   T   recommended 0.708   F   0   -100    T   recommended
    5193751 AGTAGCTTGCGCGGA[C/T]GGGGGGGGG   consensus_32    227 1   species 0   0   0   T   1   1   T   not_recommended 0.75    F   0   -100    T   not_recommended
    5193254 TAAAAAAAAAAAAAA[G/T]ATTCATCC    consensus_26    192 1   species 0   0   0   T   1   0   T   not_recommended 0.726   F   0   -100    T   neutral

So if I filter based in that $11=1 and $20 needs to be "neutral" or "not_recommended" I would get this

       5306083  TGATCAATCTCATAAC[A/C]AAAAAAAAA  consensus_24    211 1   species 0   0   0   T   0   7   T   recommended 0.708   F   0   -100    T   recommended

Upvotes: 1

Views: 556

Answers (1)

karakfa
karakfa

Reputation: 67507

awk '$11!=1 && ($20==2 || $20==3)' infile.txt > out.txt

should do.

UPDATE: based on the input given, you should get two lines in the output for this condition

$ awk '$11==1 && ($20=="not_recommended" || $20=="neutral")' file

5193751 AGTAGCTTGCGCGGA[C/T]GGGGGGGGG   consensus_32    227 1   species 0   0   0   T   1   1   T   not_recommended 0.75    F   0   -100    T   not_recommended
5193254 TAAAAAAAAAAAAAA[G/T]ATTCATCC    consensus_26    192 1   species 0   0   0   T   1   0   T   not_recommended 0.726   F   0   -100    T   neutral

But I guess, what you mean is you want the negation of this which is different from your original post

$ awk '$11!=1 || ($20!="not_recommended" && $20!="neutral")' file

5306083 TGATCAATCTCATAAC[A/C]AAAAAAAAA  consensus_24    211 1   species 0   0   0   T   0   7   T   recommended 0.708   F   0   -100    T   recommended

Upvotes: 1

Related Questions