title: sed - replace several consecutive lines matching pattern
body: <p>I am trying to replace two consecutive lines in a file with my text. For example:<br>
  <strong>testfile.rb</strong></p>
  
  <pre><code>class Test
    def procedure
      nil
    end
  end
  </code></pre>
  
  <p>I am trying to achieve this:<br>
  <strong>testfile.rb</strong></p>
  
  <pre><code>class Test
    def procedure
      nil
    finish
  finish
  </code></pre>
  
  <p>So I need to replace last 2 lines but this doesn't work:</p>
  
  <pre><code>sed -i 's/^\s\send\nend/  finish\nfinish/' testfile.rb
  </code></pre>
  
  <p>I understand that it fails because replacement is line by line. But how can I do it?</p>