Re: change paragraphs to long lines

George Georgalis <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <CAHK3FNxLS9D5RsSGfqpbTzRBMkj1PgkMHQkO82yehzVtbDzY3A@mail.gmail.com>
Here's the private email, the author intended it for the list. Regards,
George

---------------------------------------

$ cat input
ONE two three one two three one two three one
TWO three one two three one two three one two
THREE one two three one two three one two

ONE two three one two three one two three one
TWO three one two three one two three one two
THREE one two three one two three one two

ONE two three one two three one two three one
TWO three one two three one two three one two
THREE one two three one two three one two
$ sed 's/^ *$/UNIQ_STR/' input | tr "\n" " " | sed 's/ UNIQ_STR /\n\n/g' |
sed '$ s/ $/\n/'
ONE two three one two three one two three one TWO three one two three one
two three one two THREE one two three one two three one two

ONE two three one two three one two three one TWO three one two three one
two three one two THREE one two three one two three one two

ONE two three one two three one two three one TWO three one two three one
two three one two THREE one two three one two three one two
-----------------------


On Tue, Nov 5, 2013 at 9:12 PM, George Georgalis <[email protected]> wrote:

> Thanks Thierry, Davide and private email!
>
> I used all your input. From the private email, a longer way of Davide's
> method, which helped me see the algorithm and get to the understanding the
> others failed due to DOS format. After fixing the line endings, I ended up
> going with Thierry's method since it seemed to handle leading blank lines
> better: sed -r '/^$/!{:a;N;/\n$/b;s|\n| |;ba}'
>
> Big help, I think I will add this as a macro in my editor. And I vote to
> add it to the sed1line file!
>
> Regards,
> -George
>
>
> On Mon, Nov 4, 2013 at 10:36 PM, George Georgalis <[email protected]>wrote:
>
>> Hello sed list, hope you are all well.
>>
>> Long time subscriber but I've not been following lately, hope this hasn't
>> come up recently.
>>
>> I have a file with double returns to denote paragraphs. I'd like to
>> retain the double returns but join all the other lines, so paragraphs have
>> long lines.
>>
>>
>> so this:
>> one two three one two three one two three one
>> two three one two three one two three one two
>> three one two three one two three one two
>>
>> one two three one two three one two three one
>> two three one two three one two three one two
>> three one two three one two three one two
>>
>> changes to this:
>> one two three one two three one two three one two three one two three one
>> two three one two three one two three one two three one two
>>
>> one two three one two three one two three one two three one two three one
>> two three one two three one two three one two three one two
>>
>> Maybe this solution would good for the sed1line file?
>>
>> Regards,
>> -George
>>
>>
>> --
>> George Georgalis, (415) 894-2710, http://www.galis.org/
>>
>
>
>
> --
> George Georgalis, (415) 894-2710, http://www.galis.org/
>



-- 
George Georgalis, (415) 894-2710, http://www.galis.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.