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

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

Re: About gawk! Is this a bug???


From: Aharon Robbins
Subject: Re: About gawk! Is this a bug???
Date: Mon, 25 Mar 2002 09:57:45 +0200

> From: "º£Ìì" <address@hidden>
> To: address@hidden
> Cc: address@hidden
> Subject: About gawk! Is this a bug???
>
>
> Hi,
>
>   I am sorry to trouble you, i have a question!
>   Just look that the things below:
>
> --------------------------------------------------
> address@hidden cat /etc/passwd
> root:x:0:0:root:/root:/bin/bash
> bin:x:1:1:bin:/bin:
> daemon:x:2:2:daemon:/sbin:
>
> address@hidden gawk '{FS="/"};{print $NF}' /etc/passwd
> root:x:0:0:root:/root:/bin/bash
> bin:
> sbin:
>
>   Why the first line of the file "/etc/passwd" is still 
> "root:x:0:0:root:/root:/bin/bash" ?
>   Is it a bug of ver3.0.4 OR just my falt? What can I do about this? Please 
> help me! Thank U very much! (^o^)
>   

See the gawk.info file, node `Field Splitting Summary' which has a
subheading labelled `Setting FS does not affect the fields.'  The
short answer is to use

        BEGIN { FS = "/" }
        { print $NF }

or to use

        awk -F/ '{ print $NF }' /etc/passwd

Arnold



reply via email to

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