mickt
asked on
Why does for loop return only the first entry from my lists?
Why does for loop return only the first entry from my lists? Stripped down script as follows.
groups=(baremetal production staging)
baremetal=(test1 test2)
production=(test3)
staging=()
for group in ${groups[@]}
do
echo $group
for host in ${!group} # only adds the 1st
do
echo $host
done
done
./test.sh
baremetal
test1
production
test3
staging
groups=(baremetal production staging)
baremetal=(test1 test2)
production=(test3)
staging=()
for group in ${groups[@]}
do
echo $group
for host in ${!group} # only adds the 1st
do
echo $host
done
done
./test.sh
baremetal
test1
production
test3
staging
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER