V
V
vipermagi2018-08-01 21:32:55
bash
vipermagi, 2018-08-01 21:32:55

How to connect pieces of sentences in one line?

There is a text file in which sentences are word-wrapped to the next line.
We need a recipe that replaces the newline with a space if the end of the line does not have an end-of-sentence sign (.?!) and the line is not empty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-08-02
@vipermagi

sed ':x {N ; s/\([^.!?]\)\n/\1 / ; /\n/!bx ; P ; D}' -i file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question