I have a properties file for setting some environment variables:
mydata.properties: VAR1=Data1 VAR2=Data2
Now I want to define a new variable VAR3, which can contain VAR1 or VAR2, for example:
mydata.properties: VAR1=Data1 VAR2=Data2 VAR3=VAR2
To make these variables available for my bash session, I use this command
source mydata.properties
Now my requirement is to print the value for VAR3 so that it can print the internal data of the original VAR2 variable, for example:
Value of VAR3 is Data2
I tried different options like
echo "Value of VAR3 is $$VAR3"
This gives me an undesirable result.
or echo "Value of VAR3 is ${$VAR3}"
This gives me an error like Value of ${$VAR3}: bad substitution
Please help me how to get this result.
source share