This question already has an answer here:

I'm trying to merge these two lines that appear periodically in a text file.


I have tried:

sed '/_\nby/_by/s' input.txt > output.txt

but, it doesn't do anything.

Do I have to escape something?

It's a text file created in ubuntu 12.04

Any suggestions?

marked as duplicate by Stephen Kitt, heemayl, Archemar, Anthon, Rui F Ribeiro May 9 '16 at 6:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


What are you trying to do in that command?

sed 'N;s/\n/ /' input.txt > output.txt seems logical. It will print perhaps the result you want. Cheers!!!!

  • Here's some more info. I'm trying to merge two lines - the first line ending with one string and the second startng with another string. I don't want to merge all the lines - only the two lines that have the two specific strings at the beginning and end. – speld_rwong May 9 '16 at 13:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.