I have three associative arrays:
declare -A start_obj end_obj gopath
start_obj['one']="start-obj-one"
start_obj['two']="start-obj-two"
end_obj['one']="end-obj-one"
end_obj['two']="end-obj-two"
gopath['start']="/path/to/start"
gopath['end']="/path/to/end"
I want to get the key and value of start_obj, end_obj arrays by the key of the gopath array, code show as below:
for t in "${!gopath[@]}"
do
current=$t"_obj"[@]
cd ${gopath[$t]}
for k in ${!current}
do
printf "[$t]key is : $k ; value is : ${current[$k]}\n"
done
done
But , the result of this code execution is :
[start]key is : start-obj-one ; value is : start_obj[@]
[start]key is : start-obj-two ; value is : start_obj[@]
[end]key is : end-obj-one ; value is : end_obj[@]
[end]key is : end-obj-two ; value is : end_obj[@]
The result I expect is:
[start]key is : one ; value is : start-obj-one
[start]key is : two ; value is : start-obj-two
[end]key is : one ; value is : end-obj-one
[end]key is : two ; value is : end-obj-two
So,how should I modify my code to get the results I expected?