sed: working with multi-line patterns

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Sed principally works with single lines.

To allow multi-line replacements, use the N option.
sed 'N; s/from\ncontinued/from...continued/' file.txt

Removing all the new lines:
sed ':a;N;$!ba;s/\n/ /g'

With perl

One can achieve the same with perl:
perl -0pe 's/from\n/to/' file.txt
where -0 tells perl to match NUL character instead of new lines.