[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
inconsistent output for field reference for a number stored as a string
From: |
Ed Morton |
Subject: |
inconsistent output for field reference for a number stored as a string |
Date: |
Sun, 7 Jun 2020 16:59:59 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 |
Using:
$ gawk --version
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
I'd have expected all of these to produce the same output:
$ echo 'a b c' | awk '{print $("2")}'
b
$ echo 'a b c' | awk '{print ($"2")}'
b
$ echo 'a b c' | awk '{print $("2")}'
b
$ echo 'a b c' | awk '{printf "%s\n", $"2"}'
b
$ echo 'a b c' | awk '{a=$"2"; print a}'
b
$ echo 'a b c' | awk '{print $"2"}'
a b c
but as you can see that last one doesn't and I don't know why. Is it a
bug or, if not, what's the explanation?
Ed.
- inconsistent output for field reference for a number stored as a string,
Ed Morton <=