Trying to match $1
of target.txt to $5
of file.txt. If there is a match then in an output.txt file $1,$1 (row underneath),$6,$4,$7
from file.txt are printed on the same line as $1
of target.txt. The input is from excel and the output should be tab-deliminated. Thank you :).
target.txt
PXL-A0000005
PXL-A0000007
PXL-A0000014
file.txt
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
PXL-A0000014ref 861093 861418 1 PXL-A0000014 SeqRxn4 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000014&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000014antiref 861418 861093 1
Desired output
PrimerSet RefPrimer AntirefPrimer SeqRxn Chr Link
PXL-A0000005 PXL-A0000005ref PXL-A0000005antiref SeqRxn4 1 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000005&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000007 PXL-A0000007ref PXL-A0000007antiref SeqRxn4 1 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000007&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
PXL-A0000014 PXL-A0000014ref PXL-A0000014antiref SeqRxn4 1 https://www.xxxx.com/add_2_cart.php?catno=PXL-A0000014&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube
awk '$1 = $5 && $1 != "" {print $1,$1,$6,$4,$7}' FS="\t" OFS="," target.txt file.txt . output.txt