Reputation: 321
I'm trying to do awk to look for part of characters .
cat myfile.txt
SIFT POLD POLH LRT MT MA
T B B N P N
null null null null null null
null null null null null null
T;.;.;.;.;. B B N P N
D P B D D M
T B B N P N
T;T;T;. B B N P;P;P N
D;. P B N P;P .
T;. B B N P;P .
In this example I want to get lines with SIFT = T (including "T;T;T;.") ; POLD = B; POLH = B; LRT = N; MT = P, MA = N
I would normally used awk to do the job , eg
awk -F'\t' '$1=="T" && $2=="B" && $3=="B" && $4=="N" && $5=="P" && $6=="N" myfile.txt
However, the command above will exclude "T;T;T;." in column 1. How can I include this too?
Upvotes: 0
Views: 38
Reputation: 85790
You can use awk
like below
$ awk '$1 ~ /T/' file
SIFT POLD POLH LRT MT MA
T B B N P N
T;.;.;.;.;. B B N P N
T B B N P N
T;T;T;. B B N P;P;P N
T;. B B N P;P .
Upvotes: 1