title: Strip last part of file by pattern - remove last certificate from chain
body: <p>I have a chain of SSL certificates like this</p>
  <pre class="lang-none prettyprint-override"><code>-----BEGIN CERTIFICATE-----
  MIICPjCCAeSgAwIBAgIRALMMpKnhRM2C7mnKI/rl8ggwCgYIKoZIzj0EAwIwgY4x
  CERT1
  -----END CERTIFICATE-----
  -----BEGIN CERTIFICATE-----
  MIIDIjCCAsegAwIBAgIOAMjnPM1wShDmOWUELuIwCgYIKoZIzj0EAwIwgagxCzAJ
  CERT2
  -----END CERTIFICATE-----
  -----BEGIN CERTIFICATE-----
  MIIDIDCCAsWgAwIBAgIOAMjnPL8JUbVSmpMadWUwCgYIKoZIzj0EAwIwbDELMAkG
  CERT3
  -----END CERTIFICATE-----
  -----BEGIN CERTIFICATE-----
  MIIDBjCCAqygAwIBAgIFFRCCEwYwCgYIKoZIzj0EAwIwgZQxFDASBgNVBAoMC0Ft
  CERT4
  -----END CERTIFICATE-----
  -----BEGIN CERTIFICATE-----
  MIIDNjCCAtugAwIBAgIJAKpBxYNyH8biMAoGCCqGSM49BAMCMIGUMRQwEgYDVQQK
  CERT5
  -----END CERTIFICATE-----
  </code></pre>
  <p>and I need to strip the last certificate from it.</p>
  <p>On MacOS/BSD command <code>split</code> has flag <code>-p</code> to split by pattern, and I used it:</p>
  <pre><code>cat cert | split -p &quot;-----BEGIN CERTIFICATE-----&quot; 
  cat xa{a,b,c,d}
  </code></pre>
  <p>I believe there is a command to do it in one line on Linux too, but on Ubuntu the command <code>split</code> is not able to split by pattern.</p>
  <p>I need to do the job using standard linux commands, such as those I tagged.</p>