title: Delete all lines after a string but the last few
body: <p>I have file which contains some lines and some numbers. I want to delete all the lines after particular string, let us say the string is 'angles'. I want to delete all the lines after angles, I can do this using sed command as follows:  </p>
  
  <pre><code>sed -n '/angles/q;p' input file
  </code></pre>
  
  <p>My question is, I want to delete all the lines after angles but want to retain the last four lines? How can I do this in sed? </p>