title: \n in variable in heredoc
body: <p>Is there any way to for a Bash heredoc to interpret '\n\' in a heredoc?</p>
  
  <p>I have an iteratively built string in a loop, something like</p>
  
  <pre><code>for i in word1 word2 word3
  do
          TMP_VAR=$i
          ret="$ret\n$TMP_VAR"
  done
  </code></pre>
  
  <p>and then I want to use the created string in a heredoc:</p>
  
  <pre><code>cat &lt;&lt;EOF &gt; myfile
  HEADER
  ==
  $ret
  ==
  TRAILER
  EOF
  </code></pre>
  
  <p>however I would like to interpret the "\n" character as newline, so that the output is</p>
  
  <pre><code>HEADER
  ==
  word1
  word2
  word3
  ==
  TRAILER
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>HEADER
  ==
  \nword1\nword2\nword3
  ==
  TRAILER
  </code></pre>
  
  <p>Is it possible? Or should I perhaps build my initial string somehow otherwise?</p>