0

I am trying to read a value from my config file and substituting it in my other file named test.env.

config file has key and value pair as below:

SERVER_NAME=testserver
HOSTNAME=localhost

test.env file

echo "server name is ${SERVER_NAME}"
echo "Server is running on host ${HOSTNAME}"

Would it be possible to automatically assign a variable in test.env file.

Expected output will be as follows:

echo "server name is testserver"
echo "Server is running on host localhost"
10
  • Which shell do you use? Commented Feb 3, 2022 at 11:29
  • I am using a bash shell Commented Feb 3, 2022 at 11:35
  • Are you trying to permantly modify test.env? Or print out its contents but with the variables substituted (based on config file)? Commented Feb 3, 2022 at 12:32
  • Why don't you want to use source? Commented Feb 3, 2022 at 12:38
  • @dan Yes, I permanently want to modify the test.env file with actual contents from config file Commented Feb 3, 2022 at 13:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.