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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -