title: Bash script: Using sed to stream a Environment variable to a file
body: <p>I am using the <code>sed</code> command in a bash script to stream a <code>COMMIT_SHA</code> value into a python file. Before running this bash script, the settings.py file has this line:</p>
  
  <pre><code>COMMIT_SHA = ""
  </code></pre>
  
  <p>After the bash script it needs to have the actual commit sha like so:</p>
  
  <pre><code>COMMIT_SHA = "56e05fced214c44a37759efa2dfc25a65d8ae98d"
  </code></pre>
  
  <p>Doing this in python would be easy, but I need to use Bash to get this done. The following is the approach I've tried:</p>
  
  <pre><code>COMMIT_SHA=`git rev-parse HEAD`
  sed $PROJECT_DIR/settings.py "^COMMIT_SHA = .*$" 'COMMIT_SHA = "$COMMIT_SHA"'
  </code></pre>
  
  <p>However this simply puts <code>COMMIT_SHA = "$COMMIT_SHA"</code> into my settings.py which isn't what I want.</p>