title: Iterating over variable name in bash script
body: <p>I needed to run a script over a bunch of files, which paths were assigned to <code>train1</code>, <code>train2</code>, ... , <code>train20</code>, and I thought 'why not make it automatic with a bash script?'.</p>
  
  <p>So I did something like:</p>
  
  <pre><code>train1=path/to/first/file
  train2=path/to/second/file
  ...
  train20=path/to/third/file
  
  for i in {1..20}
  do
      python something.py train$i
  done
  </code></pre>
  
  <p>which didn't work because <code>train$i</code> echoes <code>train1</code>'s name, but not its value.</p>
  
  <p>So I tried unsuccessfully things like <code>$(train$i)</code> or <code>${train$i}</code> or <code>${!train$i}</code>.
  Does anyone know how to catch the correct value of these variables?</p>