In bash 4.3 script, I have variables:
environment="local" config_local=("a" "b" "b" "d") copy_from="config_${environment}"
I want to copy values from array with name stored in copy_from
to another array named config
.
I tried this and some variations:
config=${!copy_from} echo "${config[@]}" config=${!copy_from[@]} echo "${config[@]}" config=("${!copy_from}") echo "${config[@]}" config=("${!copy_from[@]}") echo "${config[@]}"
but I can't copy whole array to config
and get only 0
or first element only:
a 0 a 0
How can I do it in bash?