title: Can I do a for loop over variables in the bash shell?
body: <p>I'm learning the shell, and I want to be able to loop over some variables. I can't seem to find anywhere where anyone has done this so I'm not sure it's even possible.</p>
  
  <p>Basically I just want to save myself trouble by using the same sed command on each of these variables. However the code obviously doesn't work. My question is, is it possible to loop over variables and if not how should I be doing this?</p>
  
  <pre><code>title="$(echo string1)"
  artist="$(echo string2)"
  album="$(echo string3)"
  
  for arg in title artist album do
      $arg="$(echo "$arg" | sed -e 's/&amp;/\&amp;amp;/g' -e 's/&lt;/\&amp;lt;/g' -e 's/&gt;/\&amp;gt;/g')"
  done
  </code></pre>
  
  <p>here is the error:</p>
  
  <pre><code>line 12: syntax error near unexpected token `$arg="$(echo "$arg" | sed -e 's/&amp;/\&amp;amp;/g' -e 's/&lt;/\&amp;lt;/g' -e 's/&gt;/\&amp;gt;/g')"'
  </code></pre>