Q:

Shell: Use variable within another variable-name (concatenation)

I have a few global variables named
ENV_URL_TEST1

ENV_URL_TEST2

ENV_URL_INT1

and so on.
My Question: -> I want to echo the value of these variables using another variable ($ENV):
echo ${ENV_URL_$ENV}

I have the String "TEST1" or "TEST2" or "INT1" and so on in that $ENV variable.
The above try results in a bad substitution error.
Is there a solution for my problem or is that not possible?
p.s. wanna use this within jenkins post build step, meaning execute shell step.

A:

Using eval :
$ ENV=TEST1
$ ENV_URL_TEST1='test_string'
$ eval echo \${ENV_URL_$ENV}
test_string
$ eval NEW_VAR=\${ENV_URL_$ENV}
$ echo $NEW_VAR
test_string

