I appear to miss understand the negated look ahead command. I'm trying to remove all lines that don't start with a certain pattern:

Validating that my regex matches:
[admin@kvm5a ~]# rbd showmapped | perl -pe 's/^\d+\s+.*\n//g' id pool image snap device

When trying to use the negated look ahead (?!) it doesn't remove the header:
[admin@kvm5a ~]# rbd showmapped | perl -pe 's/^?!\d+\s+.*\n//g' id pool image snap device 0 rbd_hdd vm-209-disk-1 - /dev/rbd0 1 rbd_hdd vm-107-disk-1 - /dev/rbd1 10 rbd_hdd vm-144-disk-1 - /dev/rbd10 11 rbd_hdd vm-145-disk-1 - /dev/rbd11 12 rbd_hdd vm-151-disk-1 - /dev/rbd12 13 rbd_hdd vm-154-disk-1 - /dev/rbd13 14 rbd_hdd vm-170-disk-1 - /dev/rbd14 15 rbd_hdd vm-204-disk-1 - /dev/rbd15 16 rbd_nvme vm-100-disk-1 - /dev/rbd16 17 rbd_hdd vm-171-disk-1 - /dev/rbd17 18 rbd_hdd vm-291-disk-1 - /dev/rbd18 19 rbd_hdd vm-285-disk-1 - /dev/rbd19 2 rbd_nvme vm-101-disk-1 - /dev/rbd2 20 rbd_nvme vm-212-disk-1 - /dev/rbd20 21 rbd_nvme vm-211-disk-1 - /dev/rbd21 22 rbd_nvme vm-212-disk-2 - /dev/rbd22 23 rbd_nvme vm-211-disk-2 - /dev/rbd23 24 rbd_nvme vm-212-disk-3 - /dev/rbd24 25 rbd_nvme vm-211-disk-3 - /dev/rbd25 26 rbd_hdd vm-300-disk-1 - /dev/rbd26 3 rbd_hdd vm-108-disk-1 - /dev/rbd3 4 rbd_hdd vm-104-disk-1 - /dev/rbd4 5 rbd_hdd vm-109-disk-1 - /dev/rbd5 6 rbd_hdd vm-123-disk-1 - /dev/rbd6 7 rbd_hdd vm-138-disk-1 - /dev/rbd7 8 rbd_hdd vm-141-disk-1 - /dev/rbd8 9 rbd_hdd vm-143-disk-1 - /dev/rbd9

In reply to Remove all lines, except those starting with pattern by bbs2web

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.