Entering edit mode
12 months ago
otieno43
▴
30
I am trying to use a combination of awk and grep to filter several files and to exclude a couple of patterns. I have several options and I just get error.
My commands that have failed are:
awk '/predicted/{flag=1;next}/detected/{flag=0}flag' $i/result_*.csv | grep "yes" | grep -v "dme" "dps" "ame" "aga" "aae" "api" | awk -F "\t" '{print $14"\t"$6}' - | sort -k1 | uniq > $i"-results-filtered.tsv"
The error "grep: dme: No such file or directory" for each of these "dps" "ame" "aga" "aae" "api".
But when when I run with one variable
awk '/predicted/{flag=1;next}/detected/{flag=0}flag' $i/result_*.csv | grep "yes" | grep -v "dme" | awk -F "\t" '{print $14"\t"$6}' - | sort -k1 | uniq > $i"-results-filtered.tsv"
It works well and exclude all the lines that contain "dme"
Again when I try these:
awk '/predicted/{flag=1;next}/detected/{flag=0}flag' $i/result_*.csv | grep "yes" | grep -v "dme,dps,ame,aga,aae,api" | awk -F "\t" '{print $14"\t"$6}' - | sort -k1 | uniq > $i"-results-filtered.tsv"
awk '/predicted/{flag=1;next}/detected/{flag=0}flag' $i/result_*.csv | grep "yes" | grep -v "dme dps ame aga aae api" | awk -F "\t" '{print $14"\t"$6}' - | sort -k1 | uniq > $i"-results-filtered.tsv"
I get results but no filter
Any help please on how I can modify this to get what I want.
Thanks.
Thank you. It worked like a charm