properly join two files based on 2 columns in common
awk ‘NR==FNR{a[$1,$2]=$3;next} ($1,$2) in a{print $0, a[$1,$2]}’ file1 file2 Look: $ cat file1 2L 5753 33158 2L 8813 33158 2L 7885 33159 2L 1279 33159 2L 5095 33158 $ $ cat file2 2L 8813 0.6 1.2 2L 5762 0.4 0.5 2L 1279 0.5 0.9 $ $ awk ‘NR==FNR{a[$1,$2]=$3;next} ($1,$2) in a{print $0, a[$1,$2]}’ file1 file2 … Read more