I have two arrays which I would like to dynamically assign to a variable depending on user input
ARRAY_ONE=('one' 'two')
ARRAY_TWO=('three' 'four')
Suppose that $opt can be either ONE or TWO depending on user input. I have a variable ARRAY_THREE that I would like to assign to the content of either ARRAY_ONE or ARRAY_TWO depending on the value of $opt.
The following snippet does not work, as it only takes the element in the first position of the assigned array:
TEMP=ARRAY_$opt
ARRAY_THREE=${!TEMP}
echo $ARRAY_THREE # 'one'