bug-gawk
[Top][All Lists]
Advanced

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

Re: Read the input as a whole


From: arnold
Subject: Re: Read the input as a whole
Date: Sat, 12 Jun 2021 21:37:55 -0600
User-agent: Heirloom mailx 12.5 7/5/10

It would be even more appropriate to

        Read
        The
        Fine
        Manual

which explains how records are split and evens offers alternatives
for reading an entire file into memory.  The manual is available
online in HTML and PDF formats, one does not even have to go to the
trouble of formatting it.

Arnold

Ed Morton <mortoneccc@comcast.net> wrote:

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



reply via email to

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