title: How to replace a hashtag curly bracket string with an environment variable by using sed
body: <p>I have being trying to write a bash script that can search recursively in a directory and replace multiple strings e.g. <code>#{DEMO_STRING_1}</code> etc with an environment variable e.g. <code>$sample1</code>.</p>
  <p>Full script:</p>
  <pre><code>#!/bin/sh
  
  find /my/path/here -type f -name '*.js' -exec sed -i \
      -e 's/#{DEMO_STRING_1}/'&quot;$sample1&quot;'/g' \
      -e 's/#{DEMO_STRING_2}/'&quot;$sample2&quot;'/g' \
      -e 's/#{DEMO_STRING_3}/'&quot;$sample3&quot;'/g' \
      -e 's/#{DEMO_STRING_4}/'&quot;$sample4&quot;'/g' \
      -e 's/#{DEMO_STRING_5}/'&quot;$sample5&quot;'/g' \
      -e 's/#{DEMO_STRING_6}/'&quot;$sample6&quot;'/g' \
      -e 's/#{DEMO_STRING_7}/'&quot;$sample7&quot;'/g' \
      -e 's/#{DEMO_STRING_8}/'&quot;$sample8&quot;'/g' \
      {} +
  </code></pre>
  <p>I can not figure out how to replace strings with hashtag with curly brackets.</p>
  <p>I tried this example: <a href="https://stackoverflow.com/questions/9205669/sed-find-and-replace-with-curly-braces">sed find and replace with curly braces</a> or <a href="https://stackoverflow.com/questions/584894/environment-variable-substitution-in-sed">Environment variable substitution in sed</a> but I can not figure out how to combine them.</p>
  <p>What I am missing? I searched also for characters that need to be escaped e.g. <a href="https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script">What characters do I need to escape when using sed in a sh script?</a> but again not the characters that I need.</p>
  <p>The specific format is throwing the following error:</p>
  <p><code>sed: bad option in substitution expression</code></p>
  <p>Where am I going so wrong?</p>
  <p><strong>Update:</strong> Sample of environment variables:</p>
  <ol>
  <li><a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></li>
  <li>/sample string/</li>
  <li>12345-abcd-54321-efgh</li>
  <li>base64 string</li>
  </ol>
  <p>All the cases above are environment variables that I would like to replace. All environment variables are within double quotes.</p>