GNU Awk 4.2.1, API: 2.0
I wanted to run
awk '{print $1 "." $2}'
i.e. add a dot between $1 and $2, but accidentially typed
awk '{print $1.$2}'
which simply concatenates $1$2:
echo 1 2 | awk '{print $1.$2}'
12
I wonder what operation is $1.$2, or why is awk not bailing out with a
syntax error on this, like in:
echo 1 2 | awk '{print $1 . $2}'
awk: cmd. line:1: {print $1 . $2}
awk: cmd. line:1: ^ syntax error
TNX
R'
GNU Awk 4.2.1, API: 2.0
I wanted to run
awk '{print $1 "." $2}'
i.e. add a dot between $1 and $2, but accidentially typed
awk '{print $1.$2}'
which simply concatenates $1$2:
echo 1 2 | awk '{print $1.$2}'
12
I wonder what operation is $1.$2,
or why is awk not bailing out with a
syntax error on this, like in:
echo 1 2 | awk '{print $1 . $2}'
awk: cmd. line:1: {print $1 . $2}
awk: cmd. line:1: ^ syntax error
TNX
R'
On 09.03.2022 20:29, Ralf Fassel wrote:
GNU Awk 4.2.1, API: 2.0
I wanted to run
awk '{print $1 "." $2}'
i.e. add a dot between $1 and $2, but accidentially typed
awk '{print $1.$2}'
which simply concatenates $1$2:
echo 1 2 | awk '{print $1.$2}'
12
I wonder what operation is $1.$2,It's parsed as four components: $ 1. $ 2
i.e. two field selector operators ($) and two numbers (1. and 2).
Janis
or why is awk not bailing out with a
syntax error on this, like in:
echo 1 2 | awk '{print $1 . $2}'
awk: cmd. line:1: {print $1 . $2}
awk: cmd. line:1: ^ syntax error
TNX
R'
On Wednesday, 9 March 2022 at 16:02:59 UTC-5, Janis Papanagnou wrote:
On 09.03.2022 20:29, Ralf Fassel wrote:
GNU Awk 4.2.1, API: 2.0It's parsed as four components: $ 1. $ 2
I wanted to run
awk '{print $1 "." $2}'
i.e. add a dot between $1 and $2, but accidentially typed
awk '{print $1.$2}'
which simply concatenates $1$2:
echo 1 2 | awk '{print $1.$2}'
12
I wonder what operation is $1.$2,
i.e. two field selector operators ($) and two numbers (1. and 2).
Janis
or why is awk not bailing out with a
syntax error on this, like in:
echo 1 2 | awk '{print $1 . $2}'
awk: cmd. line:1: {print $1 . $2}
awk: cmd. line:1: ^ syntax error
TNX
R'
Try echo 3 4 | gawk "{print $1.$2}" => 34 ( no 1's or 2's)
Try echo 3 4 | gawk "{print $1xyz$2}" => 34 (no xyz either)
echo 3 4 | gawk "{print $1.xyz$2}"=> 34 (no xyz either)
echo 3 4 | gawk "{print $1..$2}" two or more decimals gets syntax error
See: converting string to numeric ignores alpha, but not 1.., that's syntax
echo 123usd 456euro | gawk "{print $1+$2}" => 576
ref: UsrGuide 6.1.4 Conversion of Strings and Numbers
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 793 |
Nodes: | 10 (1 / 9) |
Uptime: | 40:05:27 |
Calls: | 11,106 |
Calls today: | 3 |
Files: | 186,086 |
Messages: | 1,751,481 |