title: bash difference between raw string and string in variable
body: <p>I wrote a little script in bash, but it only worked when I stored the string as a variable, and I'd like to know why. Here's the summary:</p>
  
  <p>When I use the string itself, bash treats it as a single entity</p>
  
  <pre><code>for word in "this is a sentence"; do
      echo $word
  done
  # =&gt; this is a sentence
  </code></pre>
  
  <p>If I save the exact same string into a variable, bash iterates over the words</p>
  
  <pre><code>sentence="this is a sentence"
  for word in $sentence; do
      echo $word
  done
  
  # =&gt; this
  # is
  # a
  # sentence
  </code></pre>
  
  <ol>
  <li>Why are these being treated differently?</li>
  <li>Is there a simple way to iterate through the words in the string without first saving the string as a variable?</li>
  </ol>