Match text from file 1 to file 2 and return specific text

I hope this makes sense and is possible.

I am trying to match $1 of panel_genes.txt with $3 of RefSeqGene.txt and when a match is found the value in $6 of RefSeqGene.txt

Example: ACTA2 is $1 of panel_genes.txt

ACTA2     NM_001613.2
ACTA2     NM_001141945.1
awk 'FNR==NR { E[$1]=$3 ; next }
{$6=$1} 1' panel_genes.txt RefSeqGene.txt > update.txt 

panel_genes.txt has only one field, so E[$1]=$3 in your snippet can't work.

what would you recommend, I tried a few different ways and am not getting the desired result. Thank you :).

Looks like your sample output is using field $5 from RefSeqGene.txt not $6. Assuming your sample output is what you require try:

awk 'FNR==NR {E[$1]; next }
$3 in E {print $3, $5}' panel_genes.txt RefSeqGene.txt > update.txt
1 Like

Thank you, works perfect :).