title: Bash create variable then assign value to it
body: <p>For this problem I have two values, <strong><em>curdir</em></strong> and  <strong><em>curlevel</em></strong>, which change throughout my script. I want to know if it's possible to create a variable and then use that value as the name for another value. For example</p>
  
  <pre><code>temp="dir_${curdir}_${curlevel}"
  $temp=$name_of_directory  **&lt;----Is there a legitimate way to do this?**
  </code></pre>
  
  <p>so if initially <code>curdir=1</code> and <code>curlevel=0</code> then
  <code>$(temp)=directory_one</code>
  is equal to</p>
  
  <pre><code>dir_1_0=directory_one
  </code></pre>
  
  <p>then later if <code>curdir=2</code> and <code>curlevel=4</code>, I can reset temp and then have </p>
  
  <pre><code>$(temp)=another_directory
  </code></pre>
  
  <p>is the same as</p>
  
  <pre><code>dir_2_4=another_directory
  </code></pre>
  
  <p>so I could make a call such as</p>
  
  <pre><code>cd $(temp)
  </code></pre>
  
  <p>which will move me to different directories when I need to</p>