[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to combine lines into paragraphs?
From: |
david kerns |
Subject: |
Re: How to combine lines into paragraphs? |
Date: |
Fri, 9 Sep 2022 08:17:52 -0700 |
$ cat /tmp/in
line1
line2
line3
line4
$ cat /tmp/tp
NF == 0 { getline l; print l; next; }
{ printf("%s%s", l == "" ? "" : FS, $0); l = $0; }
END { print "" }
$ awk -f /tmp/tp /tmp/in
line1 line2
line3 line4
On Fri, Sep 9, 2022 at 7:56 AM Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> ===
> line1
> line2
>
>
> line3
> line4
> ===
>
> For example, for the above input, the output should be the following
>
> ===
> line1 line2
>
> line3 line4
> ===
>
> What is the most succinct way to do so in awk?
>
> --
> Regards,
> Peng
>
>