Treat value of variable as env variable

Hi All,

I have a requirement where I have a config file, which contains 2 coulmn.values of first column are environmnet variable, whose value is defined in an environment file.

In my script I need to read the config file, and get the value of the config file variable from env file.

I have written below code. But its is not able to interprite the value from environment file.

environment file details.

export CONFIG=${APPS}/bin/config/${Application}
export DATA=${APPS}/DATA/${Application}

config file

CONFIG 30
DATA    30

My code

.<filepath>/EnvFile
 
 
if [ -f config.txt ]
then
        Directory=( $(cat config.txt | awk '{print $1}') )

 for Dir in ${Directory[@]} ; 
 do   
  ....
.....
echo $Dir
....
....
.....

Expected result:

Echo $DIR 
 
 ${APPS}/bin/config/${Application}
${APPS}/DATA/${Application}

Current Result :

echo $DIR 
 
CONFIG 
DATA    

I tried with various options as echo `$DIR`, echo ${Dir} but nothing is helping.

I can make any suggested changes in config file, but can't make changes in evnrionment file.

Appriciate your help.

echo ${!Dir}

I'm not sure what you are after. Are you wanting to effectively embed your environment script into your main script, i.e. have a common bit of code for all scripts to call in? If so:-

.  /path/to/script        # Note the space after the full stop
echo "CONFIG value from environment script is $CONFIG"
echo
echo "Running CONFIG 30"
$CONFIG 30

Have I missed the point?

Robin