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.
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