How to replace sequence identifiers in a fasta with OTU IDs from another file?
You can do it with bash quiet easy. First create a backup of your fasta file with
cp otu.fasta otu_backup.fasta

Then you can run:
while IFS=&quot; &quot; read -r otu fastaId rest; 
do
sed -E -i &quot;s/&gt;$fastaId .+/&gt;$otu/&quot; otu.fasta; done &lt; ids.txt;
done &lt; OTU_ID.txt

What does the code?
With IFS=&quot; &quot; you declare a whitespace as field seperator and by reading each line of your OTU_ID.txt, you have the two variables otu and fastaId which hold the otu name and the id of the Fasta Header.
Within the while loop, sed is looking each loop for the corresponding id within a RegEx and substitute it with the corresponding otu name. By using the -i option, you overwrite the existing file. This is why you need to create a backup.