|
From: | Ed Morton |
Subject: | Re: Read the input as a whole |
Date: | Fri, 11 Jun 2021 09:28:04 -0500 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
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.
Ed. On 6/11/2021 9:06 AM, Peng Yu wrote:
Hi, 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 other? $ builtin printf '%s\n%s' abc 123 | awk.sh -e 'BEGIN { RS=""; getline; print $0 }' abc 123 $ builtin printf '%s\n%s\n' abc 123 | awk.sh -e 'BEGIN { RS="^$"; getline; print $0 }' abc 123
[Prev in Thread] | Current Thread | [Next in Thread] |