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: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 09:05:33 |
Calls: | 9,822 |
Calls today: | 1 |
Files: | 13,757 |
Messages: | 6,190,746 |