I have a file with variables in it like below, however I want to use this file as a template and replace the variables with its actual value.
Is there a way to read the file contents and evaluate the variables?
#my script
template=$(cat script.template)
MY_VAR="my_data"
echo $template
The above script should read the below file, and replace MY_VAR
with the string my_data
# script.template
export MY_VAR=${MY_VAR}
Is there a way to accomplish this with bash?
# expected output
export MY_VAR=my data