Kapil N Joshi Kapil N Joshi - 5 months ago 16
Perl Question

delete fulfilling condition row from a file

I have a file

chrM 1114 A A 555 G 52 9.8 xyz
chrM 1256 A A 555 G 0 inf xac
chrM 1184 A A 400 G 50 8 cxv
chrM 1148 p q 500 G 100 5 asad
chrM 2500 x x 555 v 0 inf dad


here the 2nd last column is the ratio of $5/$6
I want to do delete those line where
$3=$4 and $8=inf if this whole condition satisfies then it should delete that line
expected output

chrM 1114 A A 555 G 52 9.8 xyz
chrM 1184 A A 400 G 50 8 cxv
chrM 1148 p q 500 G 100 5 asad


i tried to do

while $3=$4
do if %8=inf
do -d
done
done

SMA SMA
Answer

Use awk simply like:

awk '{if ($3 != $4 && $8 != "Inf") { print $0 } }' myfile.txt