title: Build a string in Bash with newlines
body: <p>I'm going through a script in Bash where, depending on the conditionals, I want to append to a variable different things and then display it at the very end. Something like this:</p>
  <pre><code>VAR=&quot;The &quot;
  
  if [[ whatever ]]; then
      VAR=&quot;$VAR cat wears a mask&quot;
  elif [[ whatevs ]]; then
      VAR=&quot;$VAR rat has a flask&quot;
  fi
  </code></pre>
  <p>But I run into difficulties if I try to use this form of building up <em>VAR</em> by appending to it when I want to occasionally append newlines into it. How would I do <code>VAR=&quot;$VAR\nin a box&quot;</code>, for example?</p>
  <p>I have seen usage of <code>$'\n'</code> before, but not when also trying to use <code>$VAR</code> because of the appending.</p>