title: sed: return last occurrence match until end of file
body: <p>Using sed, how do I return the last occurance of a match until the End Of File?
  (FYI this has been simplified)</p>
  
  <p>So far I've tried:</p>
  
  <pre><code>sed -n '/ Statistics |/,$p' logfile.log
  </code></pre>
  
  <p>Which returns all lines from the first match onwards (almost the entire file)</p>
  
  <p>I've also tried:</p>
  
  <pre><code>$linenum=`tail -400 logfile.log | grep -n " Statistics |" | tail -1 | cut -d: -f1`
  sed "$linenum,\$!d" logfile.log
  </code></pre>
  
  <p>This works but won't work over an ssh connection in one command, really need it all to be in one pipeline.</p>
  
  <p>Format of the log file is as follows:</p>
  
  <p>(There are statistics headers with sub data written to the log file every minute, the purpose of this command is to return the most recent Statistics header together with any associated errors that occur after the header)</p>
  
  <pre><code>Statistics |
     Stuff
     More Stuff
     Even more Stuff
  Statistics |
     Stuff
     More Stuff
  Error: incorrect value
  Statistics |
     Stuff
     More Stuff
     Even more Stuff
  Statistics |
     Stuff
  Error: error type one
  Error: error type two
  </code></pre>
  
  <p>EOF</p>
  
  <p>Return needs to be:</p>
  
  <pre><code>Statistics |
     Stuff
  Error: error type one
  Error: error type two
  </code></pre>