I have this sed expression:
<code>sed -ne '1,/DO-NOT-TOUCH-BEGIN/p' filename.txt
</code>
<code>sed -ne '1,/DO-NOT-TOUCH-BEGIN/p' filename.txt
</code>
sed -ne '1,/DO-NOT-TOUCH-BEGIN/p' filename.txt
This outputs every line up to and include the line that contains DO-NOT-TOUCH-BEGIN.
How do I modify this command so that it appends a newline after the DO-NOT-TOUCH-BEGIN?
Example:
<code>hello
there
DO-NOT-TOUCH-BEGIN
not
this
DO-NOT-TOUCH-END
extra
lines
</code>
<code>hello
there
DO-NOT-TOUCH-BEGIN
not
this
DO-NOT-TOUCH-END
extra
lines
</code>
hello
there
DO-NOT-TOUCH-BEGIN
not
this
DO-NOT-TOUCH-END
extra
lines
becomes:
<code>hello
there
DO-NOT-TOUCH-BEGIN
</code>
<code>hello
there
DO-NOT-TOUCH-BEGIN
</code>
hello
there
DO-NOT-TOUCH-BEGIN
There is a blank line after DO-NOT-TOUCH-BEGIN
I also want something similar for the other side, where it prepends a newline before the match.
<code>sed -ne '/DO-NOT-TOUCH-END/,$p' filename.txt
</code>
<code>sed -ne '/DO-NOT-TOUCH-END/,$p' filename.txt
</code>
sed -ne '/DO-NOT-TOUCH-END/,$p' filename.txt
So the output should be:
<code>
DO-NOT-TOUCH-END
extra
lines
</code>
<code>
DO-NOT-TOUCH-END
extra
lines
</code>
DO-NOT-TOUCH-END
extra
lines
There is a blank line before DO-NOT-TOUCH-END.