I need to read two config files in a shell script. In that I need to assign a value from one config file to another. I 'm using bash.
config_env.txt
prefix=tab_
config_properties.txt
table_name=${prefix}account
So, when I read these two files in a shell script, I need to substitute the value of prefix in the variable table_name and then output it to a different file.
I could get the value to be printed in the shell script but I need to pass these variables to a different program which I 'm not able to get it work.
For now I managed to work like this:
. ./config_env.txt
. ./config_properties.txt
echo "table name is : $table_namef"
Output is
table name is : tab_account
How do I get this to write to a different output file?
. ./config_env.txt
while read line
do
eval echo $line >>new_properties.txt
done < ./config_properties.txt
Each line is evaluated first, expanding any shell variables into their respective values. The problem comes when malicious commands are included in the file. But given that the file is essentially a configuration shell script, it should be safe (or you are already screwed).