Remove previous lines then join when SED finds expression -
i'm trying join sentences in document, of sentences have been split apart empty line in between. example:
the dog chased after ball
that thrown owner.
the ball travelled quite far.
to:
the dog chased after ball thrown owner.
the ball travelled quite far.
i thinking search empty line , beginning of next line lower case character. copies line, removes , empty line above it, , appends copied sentence other broken sentence (sorry confusion).
i'm new sed , tried command:
sed "/$/{:a;n;s/\n\(^[a-z]* .*\)/ \1/;ba}"
but once , removes empty line , not appending 2nd half of broken sentence first part.
please help.
this should trick:
sed ':a;$!{n;n};s/\n\n\([a-z]\)/ \1/;ta;p;d' sentences
Comments
Post a Comment