There are lot of questions about replacing multi-newlines to one newline but no one is working for me.
I have a file:
first line
second line MARKER
third line MARKER
other lines
many other lines
我需要将以下两条新路线(如果有的话)替换为一条新线:MARKER
。 结果是:
first line
second line MARKER
third line MARKER
other lines
many other lines
I tried sed :a;N;$!ba;s/MARKER
/MARKER
/g
Fail.
sed
is useful for single line replacements but has problems with newlines. It can t find
I tried perl -i -p -e s/MARKER
/MARKER
/g
Fail.
This solution looks closer, but it seems that regexp didn t reacts to
.
Is it possible to replace
only after MARKER
and not to replace other
in the file?
I am interested in one-line-solution, not scripts.