Skip to content
Advertisement

How to stop newline chars from escaping OLD gnu sed command

I am trying to replace a line in a file with multiple lines. When I had only one new line char ( ‘$’n ). it worked fine, however when I use two of them, it escapes my sed and the file wont run anymore.

JavaScript

File.txt:

JavaScript

DesiredOutput

JavaScript

Actual Output

JavaScript

Advertisement

Answer

Using older BSD sed you can do:

JavaScript

This should work with newer gnu-sed as well. However newer gnu-sed may just need:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement