I am comparing the values in column 3 from two files, file1 and file2. When the column's value does not match across file1 and file2, code it as 0. When the column's value does match across file1 and file2, code it as 1. For example:
file 1
fid1 iid1 693 900 399
fid2 iid2 589 209 485
file2
fid0 iid0 693 448 932
fid8 iid8 482 548 589
desired output
fid1 iid1 693 900 399 1
fid2 iid2 589 209 485 0
I can get this output in awk, using awk 'FNR==NR{a[$3]++;next}a[$3]' file1 file2
output
fid1 iid1 693 900 399
But, I cannot figure out how to code a new variable based on the a[$3] array comparison, instead of printing just the rows from file1 that match.