I am currently working on a script that receives the input string and then use it as the defined array name. But I stuck with this, thanks in advance
a=(1 2 3)
b=(4 5 6)
c=(7 8 9)
if input from user is "a", I want the result_array will be like (1 2 3)?
a=(1 2 3); b=(4 5 6); input="a"; result_array=("${${input}[@]}"); echo ${result_array[@]}
bash: ${${input}[@]}: bad substitution
All I want is: result_array=("${${input}[@]}") => result_array=("${a[@]}") = (1 2 3)
Note: I dont want to use IF statements like "if input = a or b or c, result_array= a or b or c", because I have to do this step many times.