I have an array called "loop".
For each element in "loop" I want to create an array whose name contains the text of the current element.
I then want to loop through each new array and print every element from each array.
This post seems to have a good solution for variables but I do not know how to adapt it to work for arrays.
My Script
#!/bin/bash
loop=(
first
second
third
)
for word in "${loop[@]}"
do
declare "${word}_holder=( hello world )"
var="${word}_holder"
echo "$var"
for i in "${!var}[@]"
do
echo "$i"
done
done
Current output
first_holder
( hello world )[@]
second_holder
( hello world )[@]
third_holder
( hello world )[@]
Desired Output
first_holder
hello
world
second_holder
hello
world
third_holder
hello
world