title: How to change a variable name in a loop
body: <p>I'm having a [very bad] blonde moment, and would like to know how I can have a changing variable name inside the following snippet of code:</p>
  
  <pre><code>sentence="This is   a sentence containing f@#cy |3tt3r5."
  for word in $sentence
  do
      echo $word
  done
  </code></pre>
  
  <p>Ideally I would like to have each of the <code>word</code>s in the <code>$sentence</code> variable be held my a unique variable. So for example <code>echo $word_1</code> would print "This" and <code>echo $word_5</code> would print "containing" ... etc. </p>
  
  <p>Should I be using arrays? </p>
  
  <p><strong>Q:</strong> How can I make a variable that keeps on changing i.e. <code>word_1</code> <code>word_2</code>.. <code>word_n</code>  until the for loop is complete.</p>