Join Two Lines in a Text File

I found myself need to join two lines in a text file if the second line starts with a certain string the other day. I know this is  a place where scripting language and tools like sed and awk shine.

I ended up writing a short Perl script to do that. A google search  led me to this sed FAQ page which shows how to do it in a sed one liner:

In this example, we want to match the string “<<=" at the beginning of one line, bring that line up to the end of the line before it, and replace the string with a single space:

     sed -e :a -e '$!N;s/\n<<=/ /;ta' -e 'P;D' file   # all seds

You got to love swiss army knife like this.