title: Using variables with sed but having escaping issues
body: <p>I'm trying to use sed to perform an inline search and replace but I think weird characters are causing issues.</p>
  
  <p>My config.inc file contains 2 lines:</p>
  
  <pre><code>$GLOBALS['industry_id'] = '1';
  yyyy
  </code></pre>
  
  <p>Something simple like this works and replaces yyyy with zzzz:</p>
  
  <pre><code>x="yyyy"
  y="zzzz"
  sed -i "s/${x}/${y}/" config.inc
  </code></pre>
  
  <p>But something like this doesn't work:</p>
  
  <pre><code>x="$GLOBALS['industry_id'] = '1';"
  y="$GLOBALS['industry_id'] = '3';"
  sed -i "s/${x}/${y}/g" config.inc
  </code></pre>
  
  <p>Do I need to escape the characters like $ [ ] ' ; (though this doesn't work either): </p>
  
  <pre><code>x="\$GLOBALS\[\'industry_id\'\] = \'1\'\;"
  y="\$GLOBALS\[\'industry_id\'\] = \'3\'\;"
  sed -i "s/${x}/${y}/g" config.inc
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Thanks
  Chris</p>
  
  <p><strong>UPDATE:</strong> Ok thanks to pfnuesel the following works:</p>
  
  <pre><code>x="\\\$GLOBALS\\['industry_id'\\] = '1';"
  y="$GLOBALS['industry_id'] = '3';"
  sed -i "s/${x}/${y}/g" config.inc
  </code></pre>