here is my bash case
first case, this what i want to do "aliasing" var
with myvarA
myvarA="variableA"
varname="A"
eval varAlias=\$"myvar"$varname
echo $varAlias
second case for array variable and looping its members, which is trivial
myvarA=( "variableA1" "variableA2" )
for varItem in ${myvarA[@]}
do
echo $varItem
done
now somehow i need to use "aliasing" technique like example 1, but this time for array variable:
eval varAlias=\$"myvar"$varname
for varItem in ${varAlias[@]}
do
echo $varItem
done
but for last case, only first member of myvarA
is printed, which is eval
evaluate to value of the variable, how should I do var array variable so eval
is evaluate to the name of array variable not the value of the variable