title: Using a shell script to replace tokens in a file
body: <p>I have a file that holds token variables. When we switch environments we want to replace those tokens correctly for the environment we're in.</p>
  
  <p>How can I do this in a Linux shell? I'm thinking awk or sed.</p>
  
  <p>Example:</p>
  
  <p>File has this data:</p>
  
  <pre><code>DB_HOST=__HOST__
  DB_PASSWORD=__PASSWORD__
  </code></pre>
  
  <p>I want to read this file, recognize the <code>__HOST__</code> and replace it with the environment variable <code>$(HOST)</code>. We would get the environment variable name from the matched string between the two underscores.</p>
  
  <p>Does anyone have a good idea how we could do this?</p>