Bash, Concatenating 2 strings to reference a 3rd variable
Posted
by
Im Fine
on Stack Overflow
See other posts from Stack Overflow
or by Im Fine
Published on 2012-06-12T04:14:08Z
Indexed on
2012/06/12
4:40 UTC
Read the original article
Hit count: 140
I have a bash script I am having some issues with concatenating 2 variables to call a 3rd.
Here is a simplification of the script, but the syntax is eluding me after reading the docs.
server_list_all="server1 server2 server3";
var1 = "server";
var2 = "all";
echo $(($var1_list_$var2));
This is about as close as I get to the right answer, it acknowledges the string and tosses an error on tokenization.
syntax error in expression (error token is "server1 server2 server3....
Not really seeing anything in the docs for this, but it should be doable.
EDIT: Cleaned up a bit
© Stack Overflow or respective owner