Bash version : 5.0.3(1)-ui-release
I don't know where I'm wrong.
1. One file "install_options.sh" with variables inside, like :
ADMIN_EMAIL="contact@john-doe.fr"
ADMIN_FIRST_NAME="John"
ADMIN_NAME="Doe"
....
2. another file : "admin_settings.txt" with data like "KEY VALUE" (withespace separator), and few value is variable:
KEY VALUE
KEY "${ADMIN_EMAIL}"
NEED_HELP PLEASE
KEY "${ADMIN_FIRST_NAME}"
...
3. When i try on cli:
$ echo "${ADMIN_EMAIL}"
I have the right output:
contact@john-doe.fr
4. I try to use while read loop:
#!/bin/bash
while read IFS= -r KEY VALUE; do
COMMAND $KEY "${VALUE}"
done < admin_settings.txt
I get output:
KEY "${ADMIN_EMAIL}"
I would like get the output with the value:
KEY contact@john-doe.fr
I have tried many things, like put source file inside the while read loop, but not working:
#!/bin/bash
while read IFS= -r KEY VALUE;
do
source install_options.sh
COMMAND $KEY "${VALUE}"
done < admin_settings.txt
Inside "admin_settings.txt", I have tried with:
KEY "${ADMIN_EMAIL}"
KEY ${ADMIN_EMAIL}
KEY "$ADMIN_EMAIL"
KEY $ADMIN_EMAIL
Same with COMMAND inside while loop, I have tried:
COMMAND $KEY "${VALUE}"
COMMAND $KEY ${VALUE}
COMMAND $KEY "$VALUE"
COMMAND $KEY $VALUE
What can I do to get the expected output?