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

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

Setting $0 to fields after changing FS


From: Ed Morton
Subject: Setting $0 to fields after changing FS
Date: Sat, 20 Nov 2010 07:23: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

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]