Assume two files: file1 and file2. file1 is a short Bash script, that references file2 in order to obtain a text string. The text string includes a variable name ($VAR1), but the variable itself is assigned a value in file1.
$ cat file1
#!/bin/bash
VAR1="World"
CMDS=$(cat file2)
echo "$CMDS"
$ cat file2
Hello $VAR1 !
Under the above setup, the variable name is not recognized correctly during the execution of file1.
$ bash file1
Hello $VAR1 !
What do I need to do so that the variable name is recognized correctly during the execution of file1?