[Top][All Lists]

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

Re: IFS system variable

From: Ian Macdonald
Subject: Re: IFS system variable
Date: Thu, 14 Feb 2002 09:36:02 -0800
User-agent: Mutt/

On Thu 14 Feb 2002 at 12:09:06 +0000, you wrote:

> That awk code won't do it, use:
>       awk -F: '$5 ~ /eric/ { print $5 }' /etc/passwd
> Fields are split (conceptually) as soon as the record is read,
> changing FS in the middle doesn't work on a correct POSIX awk
> (such as gawk or mawk or recent Bell Labs awk).

I tested my one-liner on gawk before mailing the suggestion.

        awk '{FS=":"; if ($5 ~ /eric/) {print $5}}' /etc/passwd

works for me. As a matter of fact, so does:

        awk --posix '{FS=":"; if ($5 ~ /eric/) {print $5}}' /etc/passwd

Ian Macdonald               | It isn't easy being the parent of a
address@hidden             | six-year-old.  However, it's a pretty small
                            | price to pay for having somebody around the
                            | house who understands computers. 

reply via email to

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