title: How to append line after a sed range match
body: <p>/etc/named.conf has record like this:</p>
  <pre><code>zone &quot;domain.com&quot; in{
    type master;
    file &quot;local/domain.com&quot;;
  };
  </code></pre>
  <p>I am trying to append the line:</p>
  <pre><code>allow-update { key &quot;update&quot;; };
  </code></pre>
  <p>after multiline matching:</p>
  <pre><code>zone &quot;domain.com&quot; in{
     type master;
  </code></pre>
  <p>With the desired result:</p>
  <pre><code>zone &quot;domain.com&quot; in{
    type master;
    allow-update { key &quot;update&quot;; };
    file &quot;local/domain.com&quot;;
  };
  </code></pre>
  <p>The code I have is very close, but it adds the line twice, once after each line in the match so I end up with:</p>
  <pre><code>zone &quot;domain.com&quot; in{
    allow-update { key &quot;update&quot;; };
    type master;
    allow-update { key &quot;update&quot;; };
    file &quot;local/domain.com&quot;;
  };
  </code></pre>
  <p>This is the sed command I'm using where $insert has the desired line to insert:</p>
  <pre><code>sed -i &quot;/zone \&quot;${domain}\&quot;/ ,  /^ *type master/a\ ${insert}&quot; &quot;$named_conf_file&quot;
  </code></pre>
  <p>Can this be fixed without some involved coding?</p>