in reply to Remove all lines, except those starting with pattern
G'day bbs2web,
There may be more to your data than you show; however, from what's in your OP, you may be overthinking the solution.
A cut-down version of your data:
$ cat fred 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
Removing ... except:
$ cat fred | perl -ne 'print unless /^[^\d]/' 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
Which is basically a double-negative for:
$ cat fred | perl -ne 'print if /^\d/' 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
— Ken
|
|---|