title: Iterate over bash arrays, substitute array name dynamically, is this possible?
body: <p>I have a script that iterates over an array of values, something like this (dumbed down for the purposes of this question) :</p>
  
  <pre><code>COUNTRIES=( ENGLAND SCOTLAND WALES )
  
  for i in ${COUNTRIES[@]}
  do                  
      echo "Country is $i "
  done
  </code></pre>
  
  <p>My question is, is it possible to substitute the array dynamically? For example, I want to be able to pass in the array to iterate over at runtime. I've tried the following but I think my syntax might be wrong</p>
  
  <pre><code>COUNTRIES=( ENGLAND SCOTLAND WALES )
  ANIMALS=( COW SHEEP DOG )
  
  loopOverSomething()
  {
      for i in ${$1[@]}
      do                  
          echo "value is $i "
      done
  }
  
  loopOverSomething $ANIMALS
  </code></pre>
  
  <p>I'm getting <code>line 22: ${$2[@]}: bad substitution</code></p>