This question already has an answer here:
I'm trying to write a script that uses sed to process lines in a text file to generate sample documentation. I've got most of the script working but I'm stuck with one edge case. Consider the following file
line-1 line-2, part2 line-3-should-be-a-very-long, line-3-continued line-4
The problem is that some, but not all, lines end in a special token (it happens to be a comma). The token indicates that the line should be concatenated with following one to produce one long line.
So in my example
line-3-should-be-a-very-long, should be concatenated with
line-3-continued to give me
line-3-should-be-a-very-long, line-3-continued (I do want to keep the comma). There is no special action on line 2 even though it contains a comma which is NOT at the end of the line.
The rest of the processing is done by piping a few
grep commands together, so a sed solution would fit well.