file1:abc|123|checkdef|456|mapijk|789|globelmn|101112|equatorfile2:abc|123|checkdef|456|mapijk|789|equatorlmn|101112|globeEXPECTED OUTPUT:ijk|789|equatorlmn|101112|globeCurrent awk script:awk 'BEGIN{OFS=FS=|} NR==FNR{a[$3]=$3;next}!($3 in a)' file1 file2This does comparison based on array content. How to compare line by line and printing only that results.
Comparing files line by line in awk with delimiter
shell script;text processing;awk;join
If I understand you correctly, you want to print a line from file2 if the 3rd field is different to the corresponding entry in file1. If so, this should do it:awk 'BEGIN{FS=|} NR==FNR{a[$1,$2]=$3;next}(a[$1,$2]!=$3)' file1  file2Yours wasn't working because you were taking $3 as the key for array a and $3 is not unique (both equator and globe are present in both files).I agree with @drewbenn that both grep and join are simpler for this particular case, but here's a Perl way of doing the same thing:perl -laF'\|' -ne '($k{$F[0].,.$F[1]}||=$F[2]) eq $F[2]||print;' file1  file2