I have a file which contains a list of words under each other where these words belong to one sentence, and then the words that belong to the next sentences are also under each other. The chunk of words related to one sentence are followed by a space as shown in Representation #2 below
Expected Output: (Representation #1):
These are the words for sentence 1
These are the words for sentence 2
Expected Input: (Representation #2):
These
are
the
words
for
sentence 1
these
are
the
words
for
sentence 2
I tried following this question but it doesn't work where I have different words for different sentences, so how can I change representation number 2 to representation number 1 in linux?
sentence 1
. Can you also have chains of blanks or tabs within a line? If so please [edit] your example to show should they be handled - left as is or converted to individual blank chars or something else. – Ed Morton Jan 04 '22 at 22:33sentence a b .
in one line – M.A.G Jan 04 '22 at 22:36sentence<blank>1
, I'm talking about chains of blanks likefoo<blank><blank>bar
, or tabs, e.g.foo<tab>bar
. – Ed Morton Jan 04 '22 at 22:38