Is it possible in Bash to store a value to variable with linked name?
I mean when variable name is stored at other variable, like here
Code:
A="abcd dcba"
B=A
C=${!B}
echo $C
So, I need to store to ${!B}
In fact I need more than this. I have arrays
Code:
small=( 'one' 'two' 'three' 'four' )
big=( 'ONE' 'TWO' 'THREE' 'FOUR' )
digit=( 1 2 3 4 )
totalNames=( 'small' 'big' 'digit' )
and I get needed values like
Code:
for name in ${totalNames[@]}; do
temp1=$( eval echo \${$name[0]} )
temp2=$( eval echo \${$name[1]} )
done
or without cycle
Code:
temp1=$( eval echo \${${totalNames[0]}[0]} )
temp2=$( eval echo \${${totalNames[0]}[1]} )
after some actions with temp1 and temp2
i need to store values to ${$name[2]} and ${$name[3]} in cycle
or to ${${totalNames[0]}[2]} and ${${totalNames[0]}[3]} out of cycle.
Is it possible?
Thanks a lot.