[illumos-Developer] awk, nawk, oawk, ...

Yuri Pankov yuri.pankov at gmail.com
Tue Apr 5 12:08:11 PDT 2011


On Tue, Apr 05, 2011 at 10:53:27PM +0400, Andrey N. Oktyabrski wrote:
> On 04/05/11 22:21, Yuri Pankov wrote:
> > On Tue, Apr 05, 2011 at 02:13:46PM -0400, Gordon Ross wrote:
> >> I also saw mention that MacOSX passed POSIX tests.  Anyone know?
> >> If so, is this GNU awk example anything one should care about?
> >
> > I guess no:
> >
> > http://pubs.opengroup.org/onlinepubs/009695399/utilities/awk.html
> > [...]
> > RS
> >      The first character of the string value of RS shall be the input
> > record separator; a<newline>  by default. If RS contains more than one
> > character, the results are unspecified.
> > [...]
> Here is a more interesting case:
> $ printf "a\nb\r\n" | /usr/bin/gawk 'BEGIN{RS="\r\n"; ORS="=\n"} {print}'
> a
> b=
> $ printf "a\nb\r\n" | /usr/bin/awk 'BEGIN{RS="\r\n"; ORS="=\n"} {print}'
> a
> b=
> 
> =

It looks the same to me, only the first character of RS is used by nawk:

$ printf "acbdc" | /usr/bin/gawk 'BEGIN{RS="dc"; ORS="=\n"} {print}'
acb=
$ printf "acbdc" | /usr/bin/nawk 'BEGIN{RS="dc"; ORS="=\n"} {print}'
acb=
c=


Yuri



More information about the Developer mailing list