help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to combine lines into paragraphs?


From: Manuel Collado
Subject: Re: How to combine lines into paragraphs?
Date: Sun, 11 Sep 2022 16:41:20 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1

El 09/09/2022 a las 16:56, Peng Yu escribió:
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?


You can use the multiline record feature of gawk.

---
BEGIN {RS=""; ORS="\n\n"}
{gsub(/\n/," "); print}
---

HTH.
--
Manuel Collado - http://mcollado.z15.es




reply via email to

[Prev in Thread] Current Thread [Next in Thread]