Help updating a file

I can not seem to figure out how to update the attached match.txt column 2 using update.txt. However, only the text before the period in updat.txt appears in match.txt.

For example, in update.txt NM_001613.2 matches NM_001613 in match.txt, so is it possible to update the record in match.txt to NM_001613.2? Thanks.

Show the input you have and the output you want please.

Sorry, I attached the input (update.txt) and the file match.txt (file to use to match the NM_). The desired output would be the match.txt updated with the new NM_.

So, NM_001613 belongs to the gene ACTA2 and after updating it would be NM_001613.2 with all the text in match.txt. Thank you.

You forgot to post the output you wanted... Right now your request is ambiguous. Show at least a line from each that causes a match to be changed and the resulting output you want please!

I have no output as I can not write a script that works.

In update.txt the gene ACTA2 is NM_001613
and that # is in match.txt but can it be updated to NM_001613.2? (which is the full # in update.txt). Thanks.

So, basically look for NM_001613 in match.txt and when it is found update it to NM_001613.2. Does this help? Thanks.

Yes, that helps. Thank you.

awk '{ sub(/\r/, "") } ; NR==FNR { N=$2 ; sub(/\..*/, "", $2); A[$2]=N; next } ; $2 in A { $2=A[$2] } 1' update.txt match.txt > outputfile

outputfile cannot be match.txt.

 awk '{ sub(/\r/, "") } ; NR==FNR { N=$2 ; sub(/\..*/, "", $2); A[$2]=N; next } ; $2 in A { $2=A[$2] } 1' update.txt match.txt > hg19_refGene.txt 

The code works great, but is there a way to format it like match.txt? The spacing in the hg19_refGene.txt is different. Thanks.

Appears to be tab-separated.

awk -v OFS="\t" '{ sub(/\r/, "") } ; NR==FNR { N=$2 ; sub(/\..*/, "", $2); A[$2]=N; next } ; $2 in A { $2=A[$2] } 1' update.txt match.txt > hg19_refGene.txt