title: How can I generate new variable names on the fly in a shell script?
body: <p>I'm trying to generate dynamic var names in a shell script to process a set of files with distinct names in a loop as follows:</p>
  
  <pre><code>#!/bin/bash
  
  SAMPLE1='1-first.with.custom.name'
  SAMPLE2='2-second.with.custom.name'
  
  for (( i = 1; i &lt;= 2; i++ ))
  do
    echo SAMPLE{$i}
  done
  </code></pre>
  
  <p>I would expect the output:</p>
  
  <pre><code>1-first.with.custom.name
  2-second.with.custom.name
  </code></pre>
  
  <p>but i got:</p>
  
  <pre><code>SAMPLE{1}
  SAMPLE{2}
  </code></pre>
  
  <p>Is it possible generate var names in the fly?</p>