1 of 3

GNU sed has a -z option that allows to use the syntax the OP attempted to apply. (man page)


$ cat alpha.txt
This is
a test
Please do not
be alarmed
$ sed -z 's/a test\nPlease do not\nbe/not a test\nBe/' -i alpha.txt
$ cat alpha.txt
This is
not a test
Be alarmed

Credits: @stéphane-chazelas mentioned this already in a comment above.