Get value of environment variables in for-loop
I have several environment variables
pam_branch
app_branch
worker_branch
I use an array to define different projects and I want to get the values of these environment variables by rebuilding them in a for-loop
declare -a project=(pam app worker)
for proj in ${project[@]}; do
branch=${proj}_branch
echo $branch
done
It prints
pam_branch
app_branch
worker_branch
but I want the _value_ of these projects.
I tried using a different syntax such as
for proj in ${project[@]}; do
branch="\$${proj}_branch"
echo $branch
done
but I am stuck and haven't found the correct syntax.