[Top][All Lists]

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

Re: Read the input as a whole

From: Ed Morton
Subject: Re: Read the input as a whole
Date: Fri, 11 Jun 2021 09:31:12 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

These kind of "how does awk work" questions would be far more appropriate to ask on Usenet at comp.lang.awk or on Stackoverlflow with the awk tag, by the way, rather then emailing the gawk providers bug mailing list with them.


On 6/11/2021 9:28 AM, Ed Morton wrote:
The first (with `RS=""`) will read the first paragraph in the file, not the whole file unless that file contains no blank lines.

The second (with `RS="^$") will read the whole file but only with gawk or another awk that supports multi-char RS. With a POSIX awk it'll treat it as if you wrote `RS="^"` and only read the first `^`-separated record.


On 6/11/2021 9:06 AM, Peng Yu wrote:

Both of the following commands can read a whole input. Are they always
the same under all possible input? Is there one preferred over the

$ builtin printf '%s\n%s' abc 123 | awk.sh -e 'BEGIN { RS=""; getline;
print $0 }'
$ builtin printf '%s\n%s\n' abc 123 | awk.sh -e 'BEGIN { RS="^$";
getline; print $0 }'

reply via email to

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