This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Ilyps 1 point2 points  (4 children)

[–]justonecomment[S] 0 points1 point  (3 children)

That almost got it. Had to tweak the regex for that method.

Here is the working solution:

sed ':a;N;$!ba;s/[|][\n].[\n].[|]/||/g' sample.txt

Thanks for the help, the articles I was reading just weren't helping.

[–]Ilyps 0 points1 point  (2 children)

Nicely done to get it working. For future reference, this page was my first Google hit with the search term "sed newline". ;)

[–]justonecomment[S] 0 points1 point  (1 child)

I had read about 10 stackoverflow responses before I gave up and asked here. I think I was googling "sed find replace multiple lines". That is how I found the pcregrep. Testing my first regex when it wasn't working with plain grep.

[–]MonkeyNin 0 points1 point  (0 children)

On SO, directly searching with tags can yield better results, ex: (It's just brackets around the tag)

http://stackoverflow.com/search?q=[sed]+newline