This is a simplified version of the problem I'm experiencing just for demonstration purposes. But the command output when it contains a variable reference doesn't seem to go through an evaluation process to populate the variable reference it contains.
So do demonstrate I create a txt file (/mnt/external.txt) with the following line of text "${var1}/filename.txt". I then do a bash script like the following:
#!/bin/bash
var1="/home/user1"
echo $(cat /mnt/external.txt)
This then outputs "${var1}/filename.txt" rather than "/home/user1/filename.txt".
Is there a way to get it to re-evaluate the output of the cat command (just used cat to demonstrate the problem) to have it populate the variable reference with the variable value instead?