Link to home
Start Free TrialLog in
Avatar of mickt
micktFlag for Ireland

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
ASKER CERTIFIED SOLUTION
Avatar of Pierre François
Pierre François
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mickt

ASKER

Cheers!