Get Variables from txt file

I want to call a txt file in bash and be able to get the values of certain variables as displayed in the text file.

For example the text file appears as follows

TXT File:

First_Name=John
Last_Name=Doe
Age=43
Home_State=NY
Link=/home/${DEST}/JohnDoe

DEST will be defined in the bash script and therefore I dont want linke just to be "home/${DEST}/JohnDoe" I want Link to have the right value of DEST

After the variables are assigned in the bash script, the following should be true if DEST=workers/basicinformation

INPUT:

echo $First_Name
echo $Last_Name
echo $Age
echo $Home_State
echo $Link

OUTPUT:

John
Doe
43
NY
/home/workers/basicinformation/JohnDoe

source should do what you want.

inside your bash script:

source /path/to/txt_file
or 
. /path/to/txt_file
1 Like