I have a file that, occasionally, has split lines. The split is signaled by the fact that the line starts with ‘+’ (possibly preceeded by spaces).
line 1
line 2
+ continue 2
line 3
...
I’d like join the split line back:
line 1
line 2 continue 2
line 3
...
using sed. I’m not clear how to join a line with the preceeding one.
Any suggestion?
This might work for you:
These are actually four commands:
NAppend line from the input file to the pattern space
s/\n\s*+//Remove newline, following whitespace and the plus
Pprint line from the pattern space until the first newline
Ddelete line from the pattern space until the first newline, e.g. the part which was just printed
The relevant manual page parts are
To add 1 or more
+lines, use: