title: awk/sed - searching between lines to return text
body: <p>i am scanning cisco configs for interfaces that have no descriptions and aren't shut down.</p>
  
  <p>if the interface doesn't have a description, it should be shut down.</p>
  
  <p>if the interface has a description, this is always the first line after the interface. i've written a script that shows me all my interfaces and descriptions using awk, but i am not sure how to do something slightly more complex.</p>
  
  <p>i've run this (if the line following 'interface' <em>does not</em> being with 'description').</p>
  
  <pre><code>awk '{if ((lastline ~ /^interface/) &amp;&amp; ($0 !~ /^ description/)) {print FILENAME ";" lastline ORS FILENAME ";" $0} lastline=$0}'
  </code></pre>
  
  <p>but the problem is, some lines begin with 'interface' and have no config at all, or have something else. so it's picking up the wrong information.</p>
  
  <p>i need something that looks at all lines between each instance of a line beginning with the word 'interface', and if there are no lines beginning with either 'description' or 'shutdown' between, then i need it to print the interface line along with the filename. bit complex for me, i'm a beginner! :(</p>
  
  <p>so for example, this file:</p>
  
  <pre><code>interface GigabitEthernet3/23
  logging event link-status
  shutdown
  interface GigabitEthernet3/24
  interface Vlan1
  description 'VLAN 1'
  interface Vlan2
  no ip address
  interface Vlan4
  shutdown
  </code></pre>
  
  <p>will return</p>
  
  <pre><code>interface GigabitEthernet3/24
  interface Vlan2
  </code></pre>