replace two newlines to one in shell command line
问题 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 I need to replace two newlines (if they exist) after MARKER to one newline. A result file should be: first line second line MARKER third line MARKER other lines many other lines I tried sed ':a;N;$!ba;s/MARKER\n\n/MARKER\n/g' Fail. sed is useful for single line replacements but has problems with