bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Field separator ignored for first record.


From: Stepan Kasal
Subject: Re: Field separator ignored for first record.
Date: Sat, 23 Oct 2004 17:15:34 +0200
User-agent: Mutt/1.4.1i

Hello,
        thank you very much for your bug report.

On Sat, Oct 23, 2004 at 01:03:34AM -0600, Les Seeley wrote:
> Why does:
> 
> gawk -F : '{ print $1 }' /etc/shadow
> 
> and 
> 
> gawk '{FS=":"; print $1 }' /etc/shadow 
> 
> produce different results?

This behaviour is correct.
The following two commands are both equivalent to your first command:

gawk 'BEGIN(FS=":"} { print $1 }' /etc/shadow
gawk '{ print $1 }' FS=: /etc/shadow

Please see the ``Advanced Notes: Changing FS Does Not Affect the Fields''
in the node "(gawk)Field Splitting Summary", eg. here:
http://www.gnu.org/software/gawk/manual/html_node/Field-Splitting-Summary.html

> awk, and nawk on other systems do not present this problem.

As mentioned in these manuals, these traditional implementations are not
POSIX compliant.
(I suspect they are not consistent with their documentation either.)

Solaris contains another awk implementation which should be POSIX compliant;
it's somewhere like /usr/xpg4/bin/awk .

Regards,
        Stepan Kasal




reply via email to

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