title: Using a variable name to create an array bash, unix
body: <p>First I should perhaps explain what I want to do...</p>
  
  <ul>
  <li>I have 'n' amounts of files with 'n' amount of lines. All I know is
  that the line count will be even.</li>
  <li>The user selects the files that they want. This is saved into an
  array called <code>${selected_sets[@]}</code>.</li>
  <li>The program will print to screen a randomly selected 'odd numbered'
  line from a randomly selected file. </li>
  <li>Once the line has been printed, I don't want it printed again...</li>
  </ul>
  
  <p>Most of it is fine, but I am having trouble creating arrays based on the contents of <code>${selected_sets[@]}</code>... I think I have got my syntax all wrong :)</p>
  
  <pre><code>for i in ${selected_sets[@]}
  do 
      x=1
      linecount=$(cat $desired_path/$i | wc -l) #get line count of every set
  
          while [ $x -le $linecount ] 
          do ${i}[${#${i}[@]}]=$x
          x=$(($x+2)) # only insert odd numbers up to max limit of linecount
          done
  done
  </code></pre>
  
  <p>The problem is <code>${i}[${#${i}[@]}]=$x</code>
  I know that I can use <code>array[${#array[@]}]=$x</code> but I don't know how to use a variable name.</p>
  
  <p>Any ideas would be most welcome (I am really stumped)!!!</p>