I am having a sed replacement issue and am hoping one of you will be able to help me. I am sure I am missing something simple.
So I have a file containing text and a quote. The quote itself could be on one line or span multiple lines. I want the quote on a new line by itself. As an example here is an example of the file
And he said "This too
shall pass"
I need to change this to
And he said
"This too shall pass"
I tried the following sed but it didn't work -- it seems to match alright but failed to get a new line
/"This/ {
N
s/"This *\n*too *\n*shall *\n*pass"/\n"This too shall pass"/
}
Try replacing the "\n" with \ and an explicit new line; like the following --
/"This/ {
N
s/"This *\n*too *\n*shall *\n*pass"/\
"This too shall pass"/
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With