-2

我有一个文件 File_1.txt

AA:BB:CC 
a@gmail.comb@gmail.com:c@yahoo.co.in -------------------------- Row1 
x@rediff.com,y@gmail.com:y@yahoo.in:z@redhat@com ---------------Row2
a@yahoo.in,c@gmail.com:b@yahoo.co.in,a@rediff.com:c@uix.xo.in---Row3

这里AA, BB,CC是三列,文件是:分隔的。

在第 1 行中,如果AAdata 与BB or AACC or BB与data 匹配,CC则 print Row 1 matched,如果不匹配,则 print Row 1 no matched

4

2 回答 2

2
$ gawk -F: 'FNR > 1 {if ($1 == $2 || $1 == $3 || $2 == $3)
                       print FNR, "match";
                     else
                       print FNR, "no match";}' < File_1.txt
于 2012-09-07T09:20:20.783 回答
0
awk -F: '{if(!($1==$2||$2==$3||$3==$1))printf("%s","not ");print"matched",$0}' file

tested below:

> cat temp
AAAA:0:12
BBBBB:2:2
CCCCC:1:1
DDDD:0:0
EEEEE:1:2
> awk -F: '{if(!($1==$2||$2==$3||$3==$1))printf("%s","not ");print"matched",$0}' temp
not matched AAAA:0:12
matched BBBBB:2:2
matched CCCCC:1:1
matched DDDD:0:0
not matched EEEEE:1:2
于 2012-09-07T09:49:36.543 回答