This question is similar to this one: Is it possible to print the content of the content of a variable with shell script? (indirect referencing)
In a file that is
a=${env1}is a good ${env2}
b=${env3}is a good ${env2}
I would like to show content of this file to:
a=tom is a good cat
b=jerry is a good mouse
I tried this:
tmp=`cat a.conf`
echo $tmp # environmental variables are not interpreted, and file format changed, hard to read
echo ${!tmp} # no ...
Besides, above idea is kinda detour.
./a.sh < file
;) Mostly that script works, except that it seems to miss default value when environment variable is missing, like this${env1:dog}
would be interpreted as dog when env1 is missing inprintenv
– Tiina Sep 15 '22 at 06:26${env1:-dog}
. – larsks Sep 15 '22 at 12:53