Не могли бы вы попробовать следующее.
awk '
FNR==NR{
a[$NF]=(a[$NF]?a[$NF] ",":"")$2
next
}
{
printf("%s %s\n",$0,($1 in a)?a[$1]:"NA")
}
' Input_file1 Input_file2
Объяснение: Добавление подробного объяснения для приведенного выше кода.
awk ' ##Starting awk program fro here.
FNR==NR{ ##Checking condition FNR==NR whioh will be TRUE when Input_file1 is being read.
a[$NF]=(a[$NF]?a[$NF] ",":"")$2 ##Creating arra a with index $NF, its value is keep appending to its own value with $2 of current line.
next ##next will skip all further lines from here.
}
{
printf("%s %s\n",$0,($1 in a)?a[$1]:"NA") ##Printing current line then either value of array or NA depending upon if condition satisfies.
}
' Input_file1 Input_file2 ##Mentioning Input_file names here.