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

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

Re: Setting $0 to fields after changing FS


From: Ed Morton
Subject: Re: Setting $0 to fields after changing FS
Date: Sat, 20 Nov 2010 11:24:44 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4

 Here's probably another symptom of the same bug, or it could be a different 
one:

$ cat file
%A Bimmler foo
%T title name
%P 20-30

$ cat t.awk
BEGIN { RS = ""; FS = "\n" }

/Bimmler/ {
        $1 = $1
        FS = " "
        $0 = $3
        printf "$0=%s\n$2=%s\n",$0,$2
}

$ awk -f t.awk file
$0=0
*_$2=_*

$ cat u.awk
BEGIN { RS = ""; FS = "\n" }

/Bimmler/ {
        $1 = $1
        FS = " "
_*print                 # <<<< NOTE: only difference*_
        $0 = $3
        printf "$0=%s\n$2=%s\n",$0,$2
}

$ awk -f u.awk file
%A Bimmler foo %T title name %P 20-30
$0=%P 20-30
_*$2=20-30*_

Note the value of $2 on the last line of output from both scripts.

Regards,

    Ed.
On 11/20/2010 7:23 AM, Ed Morton wrote:
I found this on cygwin on Windows XP. Notice the control characters on the final line of output.

Reading http://www.gnu.org/manual/gawk/html_node/Bugs.html didn't point me to the list of known bugs, so I don't know if this is a known problem or not.

Regards,

    Ed Morton.

------------------------------------------------------------------------------------------------------------------------

$ gawk --version | head -2
GNU Awk 3.1.6
Copyright (C) 1989, 1991-2007 Free Software Foundation.

$ cat -v tst.awk
BEGIN {
        FS = "-"
        $0="foo,bar"
        printf "FS=<%s> NF=<%d> $0=<%s> $1=<%s> $2=<%s>\n",FS,NF,$0,$1,$2

        FS = ","
        $0 = $1
        printf "FS=<%s> NF=<%d> $0=<%s> $1=<%s> $2=<%s>\n",FS,NF,$0,$1,$2

        $0 = $2
        printf "FS=<%s> NF=<%d> $0=<%s> $1=<%s> $2=<%s>\n",FS,NF,$0,$1,$2

}

$ gawk -f tst.awk | cat -v
FS=<-> NF=<1> $0=<foo,bar> $1=<foo,bar> $2=<>
FS=<,> NF=<2> $0=<foo,bar> $1=<foo> $2=<bar>
FS=<,> NF=<1> $0=<M-TM-^]^T> $1=<M-TM-^]^T> $2=<>




reply via email to

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