This is working on some tools as regex101.com but I cannot make it work with sed.
Blocks:
dn: abcd1,ou=test
aaaaa
bbbb
1111
dn: abcd2,ou=test
33333
ddddd
aaaaa
dn: qwert,ou=test
55555
hhhh
dddd
I want to match and replace with nothing every block that starts with dn: abcd
. A block always ends with \n\n
.
Regexp: (?s)\b(?:(?!\n\n).)*?\bdn: abcd\b(?:(?!\n\n).)*
Is it possible to achieve with sed?
perl is a better choice for this task.
$ perl -00ne 'print if not /^dn: abcd/' file
or
$ perl -ne 'print if not /^dn: abc/ .. /^$/' file
dn: qwert,ou=test
55555
hhhh
dddd