title: Escaping ampersand within a string variable using sed
body: <p>I am replacing the text <code>SUBJECT</code> with a value from an array variable like this: </p>
  
  <pre><code>#!/bin/bash
  
  # array of subjects, the ampersand causes a problem.
  subjects=("Digital Art" "Digital Photography" "3D Modelling &amp; Animation")
  
  echo $subjects[2] # Subject: 3D Modelling &amp; Animation
  
  sed -i -e "s/SUBJECT/${subjects[2]}/g" test.svg
  </code></pre>
  
  <p>Instead of replacing the text <code>SUBJECT</code>, the resulting text looks like this:</p>
  
  <pre><code>3D Modelling SUBJECT Animation
  </code></pre>
  
  <p>How can I include the ampersand as a literal <code>&amp;</code> in sed and also have it echo correctly?</p>