Trying to match $5
of file1.txt to $1
of file2.txt and if there is a match copy $6
of file2.txt and paste it to $7
of file1.txt. My attempt is below but it does not seem to produce the desired output. Thank you :).
awk 'NR==FNR{A[$5]=$1; next} A[$6] {$6=$6 " " A[$7]}1' file2.txt file1.txt > match.txt
File1.txt
RefPrimer ref antiref omosome PrimerSet SeqRxn Link
AntirefPrimer antiref ref omosome
PXL-A0000005ref 69066 69311 1 PXL-A0000005 SeqRxn4
PXL-A0000005antiref 69311 69066 1
PXL-A0000007ref 69700 70033 1 PXL-A0000007 SeqRxn4
PXL-A0000007antiref 70033 69700 1
File2.txt
PXL-A0000005 chr1 69066 69311 DTE3504500000005 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000005&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000007 chr1 69700 70033 DTE3504500000007 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000007&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
Desired output
RefPrimer ref antiref omosome PrimerSet SeqRxn Link
AntirefPrimer antiref ref omosome
PXL-A0000005ref 69066 69311 1 PXL-A0000005 SeqRxn4 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000005&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000005antiref 69311 69066 1
PXL-A0000007ref 69700 70033 1 PXL-A0000007 SeqRxn4 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000007&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000007antiref 70033 69700 1