title: Print lines from config files for specific section only
body: <p>I have config files with many sections. I need to collect all lines from specific section. The section may appear several times in the one file. 
  For example:</p>
  
  <pre><code>serviceA:
     ports:
       8080
       1323
  serviceB:
    test:
        MMMM
    ports:
       8081
       3123
    network:
      ddddd
  </code></pre>
  
  <p>I read this article <a href="https://www.shellhacks.com/sed-awk-print-lines-between-two-patterns/" rel="nofollow noreferrer">https://www.shellhacks.com/sed-awk-print-lines-between-two-patterns/</a> and start.</p>
  
  <p>Pattern for the start of section is simple, it is <code>/ports:/</code> but pattern for the end of section is not so simple it could be any name, something like <code>[a-zA-Z]+:</code></p>
  
  <p>I try to use pattern <code>[a-zA-Z]+:</code> in awk and sed.</p>
  
  <p>In awk. It print only names of sections</p>
  
  <pre><code>awk '/ports:/,/[a-zA-Z]+:/' file
      ports:
      ports:
  </code></pre>
  
  <p>In sed. It print from first ports to end of file</p>
  
  <pre><code>sed -n '/ports:/,/[a-zA-Z]+:/p' file
  ports:
           8080
           1323
      serviceB:
        test:
           MMMM
        ports:
           8081
           3123
        network:
          ddddd
  </code></pre>
  
  <p>I thought the problem was that pattern <code>[a-zA-Z]+:</code> match with ports: and deсide to exclude ports:.
   <code>^\s*((?!ports)[a-zA-Z]+:)+</code> 
  This pattern works ok in online regex tester - <a href="https://regex101.com/" rel="nofollow noreferrer">https://regex101.com/</a></p>
  
  <p>awk prints from first ports to end of file</p>
  
  <pre><code>awk '/ports:/,/^\s*((?!ports)[a-zA-Z]+:)+/' file
  ports:
               8080
               1323
          serviceB:
            test:
               MMMM
            ports:
               8081
               3123
            network:
              ddddd
  </code></pre>
  
  <p>Currently, I found only one case</p>
  
  <pre><code>awk '/ports:/,/network:|serviceB:/' 
    ports:
        8080
        1323
  serviceB:
    ports:
        8081
        3123
  network:
  </code></pre>
  
  <p>But, I do not know all possible names for sections.
  I need an universal solution.</p>