Kindly consider below files: File 1:boo,194,2322foo,999,7559File 2: boo,2322boo,4526foo,4222foo,4223I need to link Field1 in File 1 with Field1 in File 2 and get the related Field2 from File 2, while excluding the result if it's equal to Field3 in File 1.The result should be: boo,4526foo,4222,4223I tried the below script, but it does not exclude the similar values.awk -F, 'NF==3{arr[$1]=$3}{if(arr[$1]==$1){print $2}}'
Exclude similar values from awk
text processing;awk;text
You need to check whether $1 is in arr and if so whether the value is different from $2 and then print:awk -F, 'FNR == NR { arr[$1] = $3; next }         { if ($1 in arr && arr[$1] != $2) print $2 }'Using FNR == NR and next is the conventional way to process lines in the first file differently from the lines in other files.  Yes, you can flatten it onto one line, but 'one-liner' is a pejorative term unless you're writing APL (or perhaps Perl).