[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] [bug report] gawk doesn’t work correctly when assign spec
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] [bug report] gawk doesn’t work correctly when assign special value to variable |
Date: |
Thu, 6 Aug 2015 13:02:26 -0400 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
On Thu, Aug 06, 2015 at 03:55:50PM +0800, Li Chao wrote:
> The second line should not be there. Because "00e4" is NOT equal to "00e1"
> obviously.
> Is it a bug or by design?
This is a tricky area. Please check the manual for the discussion
of "String Type versus Numeric Type":
http://www.gnu.org/software/gawk/manual/html_node/Variable-Typing.html
I think the command-line assignment results in a variable of type STRNUM.
> 3. Workaround:
> gawk -v var="00e1" '$2==""var' 1.txt
> gawk -v var="^00e1$" '$2~var' 1.txt
These examples may also be helpful:
bash-4.2$ gawk 'BEGIN {var = "00e1"} $2 == var' 1.txt
00e1 00e1
bash-4.2$ gawk 'BEGIN {var = 00e1} $2 == var' 1.txt
00e1 00e1
00e2 00e4
Regards,
Andy
- [bug-gawk] [bug report] gawk doesn’t work correctly when assign special value to variable, Li Chao, 2015/08/06
- Re: [bug-gawk] [bug report] gawk doesn’t work correctly when assign special value to variable,
Andrew J. Schorr <=
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Aharon Robbins, 2015/08/07
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Hermann Peifer, 2015/08/07
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Andrew J. Schorr, 2015/08/09
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Andrew J. Schorr, 2015/08/09
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Hermann Peifer, 2015/08/10
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Andrew J. Schorr, 2015/08/10
- Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable, Hermann Peifer, 2015/08/11
Re: [bug-gawk] [bug report] gawk doesn’t work correctly when assign special value to variable, Jarno Suni, 2015/08/10