title: Edit YAML file with Bash
body: <p>I'm trying to edit the following YAML file</p>
  <pre><code>db:
    host: 'x.x.x.x.x'
    main:
      password: 'password_main'
    admin:
      password: 'password_admin'
  </code></pre>
  <p>To edit the <code>host</code> part, I got it working with</p>
  <pre><code>sed -i &quot;/^\([[:space:]]*host: \).*/s//\1'$DNS_ENDPOINT'/&quot; config.yml
  </code></pre>
  <p>But I can't find a way to update the password for <code>main</code> and <code>admin</code> (which are different values).</p>
  <p>I tried to play around with <code>\n</code> and <code>[[:space:]]</code> and got different flavours of:</p>
  <pre><code>sed -i &quot;/^\([[:space:]]*main:\n*[[:space:]]*password: \).*/s//\1'$DNS_ENDPOINT'/&quot; config.yml
  </code></pre>
  <p>But never got it to work.
  Any help greatly appreciated!</p>
  <p><strong>Edit</strong> - Requirement: no external binaries/tools. Just good ol' bash.</p>