Не могли бы вы попробовать следующее.
awk 'FNR==NR{a[$1,$2,$3]=$NF;next} {print $0,($1,$2,$3) in a?a[$1,$2,$3]:"NA"}' Input_file1 Input_file2
ИЛИ с созданием переменной для полей в соответствии с комментарием Эда сэра.
awk '{var=$1 OFS $2 OFS $3} FNR==NR{a[var]=$NF;next} {print $0,var in a?a[var]:"NA"}' Input_file1 Input_file2
Вывод будет следующим.
31431 37150 100 14100 10100
31431 37131 100 14100 NA
31431 37201 100 14100 12100
31431 37478 100 14100 NA
31431 37471 100 14100 14100
Объяснение: Добавление пояснения к приведенному выше коду сейчас.
awk '
{
var=$1 OFS $2 OFS $3 ##Creating a variable named var whose value is first, second ansd third field of current lines of Input_file1 and Input_file2.
}
FNR==NR{ ##Checking condition FNR==NR which will be TRUE when first Input_file1 is being read.
a[var]=$NF ##Creating an array named a whose index is variable var and value is $NF of curent line.
next ##next keyword will skip all further lines from here.
}
{
print $0,var in a?a[var]:"NA" ##Printing current line value and along with that printing either value of a[var] or NA based upon if var present in array a then print a[var] else print NA.
}' Input_file1 Input_file2 ##Mentioning Input_file names here.