title: Linux bash - dynamic config file
body: <p>I try to combine two bash files to create a dynamic configuration file. One of these files (settings.sh) contains variables and the other (config.sh) commands to execute on them.</p>
  
  <p>For instance, in settings.sh I have </p>
  
  <pre><code>DATABASE='name_of_the_db'
  USER='name_of_the_user'
  </code></pre>
  
  <p>and config.sh contains</p>
  
  <pre><code>. settings.sh
  [...]
  'NAME': '$DATABASE',
  'USER': '$USER',
  [...]
  </code></pre>
  
  <p>I'm struggling to create a command that would get the variable in the first file and insert it in the second, rendering a new file (settings.py) containing</p>
  
  <pre><code>'NAME': 'name_of_the_db',
  'USER': 'name_of_the_user',
  </code></pre>
  
  <p>I tried a command like</p>
  
  <p>cat &lt; settings.py
  [...]
  EOF</p>
  
  <p>as proposed here <a href="https://stackoverflow.com/questions/2500436/how-does-cat-eof-work-in-bash">How does ` cat &lt;&lt; EOF` work in bash?</a> but this does obviously not perform any variable replacement.</p>
  
  <p>Thank you in advance!</p>