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 scripttemplate=$(cat script.template)MY_VAR=my_dataecho $templateThe above script should read the below file, and replace MY_VAR with the string my_data# script.templateexport MY_VAR=${MY_VAR}Is there a way to accomplish this with bash?# expected outputexport MY_VAR=my data
How to replace variable strings in a file?
shell;template
Sure, use envsubst It's part of GNU get textenvsubst < source > destination