FlorianAwk
Programmer
Hello !
I want to filter a text file. The fields $1 and $2 are useless. The fields $3 and more must be searched in another text file (a kind of dictionary). The result seems to be good but it is not. I need your help.
./myProgram.bin
it gives:
04 MOCOS EMREA ROE
04 SOMONI MOTO
04 SOMONI MOTO
05 CHERIF
05 CHERIF
05 CHERIF MC UHA SRRE TIO EFREA
06 CHAMOIS
./myProgram.bin | awk ' NR > 1 {v="true"; mem=$0; for (i=3;i<=NF;i++){ mot=$i; "grep -c "mot" dictionary.txt"|getline cmpt; if ( cmpt == "0"){ v="false";};}; if (v == "true") {print "good " mem;} else print "bad "mem;}'
It gives:
good 04 MOCOS EMREA ROE
good 04 SOMONI MOTO
good 04 SOMONI MOTO
good 05 CHERIF
good 05 CHERIF
bad 05 CHERIF MC UHA SRRE TIO EFREA
good 06 CHAMOIS
Ok for most of them but EMREA is not in my dictionary.
What am I doing wrong ?
I want to filter a text file. The fields $1 and $2 are useless. The fields $3 and more must be searched in another text file (a kind of dictionary). The result seems to be good but it is not. I need your help.
./myProgram.bin
it gives:
04 MOCOS EMREA ROE
04 SOMONI MOTO
04 SOMONI MOTO
05 CHERIF
05 CHERIF
05 CHERIF MC UHA SRRE TIO EFREA
06 CHAMOIS
./myProgram.bin | awk ' NR > 1 {v="true"; mem=$0; for (i=3;i<=NF;i++){ mot=$i; "grep -c "mot" dictionary.txt"|getline cmpt; if ( cmpt == "0"){ v="false";};}; if (v == "true") {print "good " mem;} else print "bad "mem;}'
It gives:
good 04 MOCOS EMREA ROE
good 04 SOMONI MOTO
good 04 SOMONI MOTO
good 05 CHERIF
good 05 CHERIF
bad 05 CHERIF MC UHA SRRE TIO EFREA
good 06 CHAMOIS
Ok for most of them but EMREA is not in my dictionary.
What am I doing wrong ?