title: Bash: remove all lines of input except last n lines
body: <p>I want to remove all lines except n last or first n lines with a short one-liner.</p>
  <p>Example:</p>
  <pre><code>---
  
  aaaa
  
  bbbb
  
  cccc
  
  dddd
  
  cat/echo/find ...  | sed &lt; all except last 2 lines &gt; 
  </code></pre>
  <p>should result</p>
  <pre><code>aaaa
  
  bbbb
  
  ---
  
  aaaa
  
  bbbb
  
  cccc
  
  dddd
  
  eeee
  
  ffff
  
  cat/echo/find ...  | sed &lt; all except last 2 lines &gt; 
  </code></pre>
  <p>should result</p>
  <pre><code>aaaa
  
  bbbb
  
  cccc
  
  dddd
  
  ---
  </code></pre>
  <p>I need this also for a very high n. So it could possible to set n=100 or so.</p>