title: excluding first and last lines from sed /START/,/END/
body: <p>Consider the input:</p>
  
  <pre><code>=sec1=
  some-line
  some-other-line
  
  foo
  bar=baz
  
  =sec2=
  c=baz
  </code></pre>
  
  <p>If I wish to process only =sec1= I can for example comment out the section by:</p>
  
  <pre><code>sed -e '/=sec1=/,/=[a-z]*=/s:^:#:' &lt; input
  </code></pre>
  
  <p>... well, almost.</p>
  
  <p>This will comment the lines <em>including</em> "=sec1=" and "=sec2=" lines, and the result will be something like:</p>
  
  <pre><code>#=sec1=
  #some-line
  #some-other-line
  #
  #foo
  #bar=baz
  #
  #=sec2=
  c=baz
  </code></pre>
  
  <p>My question is: <strong>What is the easiest way to exclude the start and end lines from a /START/,/END/ range in sed</strong>?</p>
  
  <p>I know that for many cases refinement of the "s:::" claws can give solution in this specific case, but I am after the generic solution here.</p>
  
  <p>In "<a href="http://www.grymoire.com/Unix/Sed.html#uh-29" rel="noreferrer">Sed - An Introduction and Tutorial</a>" Bruce Barnett writes: "I will show you later how to restrict a command up to, but not including the line containing the specified pattern.", but I was not able to find where he actually show this.</p>
  
  <p>In the "<a href="http://sed.sourceforge.net/sed1line.txt" rel="noreferrer">USEFUL ONE-LINE SCRIPTS FOR SED</a>" Compiled by Eric Pement, I could find only the inclusive example:</p>
  
  <pre><code># print section of file between two regular expressions (inclusive)
  sed -n '/Iowa/,/Montana/p'             # case sensitive
  </code></pre>