Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

There are two ways to write error-free programs; only the third one works.


devel / comp.lang.awk / Re: what operation is $1.$2 ?

SubjectAuthor
* what operation is $1.$2 ?Ralf Fassel
+- Re: what operation is $1.$2 ?Neil
+* Re: what operation is $1.$2 ?Janis Papanagnou
|+* Re: what operation is $1.$2 ?J Naman
||`- Re: what operation is $1.$2 ?Janis Papanagnou
|`- Re: what operation is $1.$2 ?Ralf Fassel
`- Re: what operation is $1.$2 ?Kpop 2GM

1
what operation is $1.$2 ?

<ygaee3alyb1.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1134&group=comp.lang.awk#1134

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.awk
Subject: what operation is $1.$2 ?
Date: Wed, 09 Mar 2022 20:29:22 +0100
Lines: 25
Message-ID: <ygaee3alyb1.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net hLgBTR7vZ6ASkHDgHlmyRgHrrFsw9vXiyT2h8tqq6FV8PiqSI=
Cancel-Lock: sha1:WTJhlPchuMobCeMGHGjfNaVrvPU= sha1:PoTek+32/+zB92z5ZGUoGRXyu8I=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Wed, 9 Mar 2022 19:29 UTC

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'

Re: what operation is $1.$2 ?

<t0b0b3$2af$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1135&group=comp.lang.awk#1135

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nddtwentyone@gmail.com (Neil)
Newsgroups: comp.lang.awk
Subject: Re: what operation is $1.$2 ?
Date: Wed, 9 Mar 2022 19:48:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t0b0b3$2af$1@dont-email.me>
References: <ygaee3alyb1.fsf@akutech.de>
Injection-Date: Wed, 9 Mar 2022 19:48:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b9cbbdef6f8e231595089bd40b6b58f8";
logging-data="2383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18W7RaP+Xkl8jvWaro7iyKz"
User-Agent: tin/2.4.4-20191224 ("Millburn") (Linux/5.4.0-104-generic (x86_64))
Cancel-Lock: sha1:s3ao2Kw7uc24w+G1UBXjXnaMQMI=
 by: Neil - Wed, 9 Mar 2022 19:48 UTC

Ralf Fassel <ralfixx@gmx.de> 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, 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'

I think $1. is the same as $1 (which is also the same as $1.234 ).

Re: what operation is $1.$2 ?

<t0b4m2$3jh$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1136&group=comp.lang.awk#1136

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: what operation is $1.$2 ?
Date: Wed, 9 Mar 2022 22:02:58 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <t0b4m2$3jh$1@dont-email.me>
References: <ygaee3alyb1.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 9 Mar 2022 21:02:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9c8850897d30268560bbae1a99b92388";
logging-data="3697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194W2fCglMbSjkBLBaUPyNq"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:orHMbsQcyHFc/YD71IC5fPfK5pk=
In-Reply-To: <ygaee3alyb1.fsf@akutech.de>
 by: Janis Papanagnou - Wed, 9 Mar 2022 21:02 UTC

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'
>

Re: what operation is $1.$2 ?

<ebe8d919-fb4b-4303-9619-8a858ed1f8f7n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1137&group=comp.lang.awk#1137

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:622a:58f:b0:2de:92c7:8859 with SMTP id c15-20020a05622a058f00b002de92c78859mr2129213qtb.191.1646875506942;
Wed, 09 Mar 2022 17:25:06 -0800 (PST)
X-Received: by 2002:a25:f45:0:b0:628:b4c9:7a9f with SMTP id
66-20020a250f45000000b00628b4c97a9fmr2119037ybp.55.1646875506491; Wed, 09 Mar
2022 17:25:06 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Wed, 9 Mar 2022 17:25:06 -0800 (PST)
In-Reply-To: <t0b4m2$3jh$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.255.232.150; posting-account=BcR7vAoAAABY9YgIIYIhD68t7wwjMvJW
NNTP-Posting-Host: 96.255.232.150
References: <ygaee3alyb1.fsf@akutech.de> <t0b4m2$3jh$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ebe8d919-fb4b-4303-9619-8a858ed1f8f7n@googlegroups.com>
Subject: Re: what operation is $1.$2 ?
From: jnaman2@gmail.com (J Naman)
Injection-Date: Thu, 10 Mar 2022 01:25:06 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 39
 by: J Naman - Thu, 10 Mar 2022 01:25 UTC

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.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'
> >
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

Re: what operation is $1.$2 ?

<t0c04h$f1k$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1138&group=comp.lang.awk#1138

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: what operation is $1.$2 ?
Date: Thu, 10 Mar 2022 05:51:29 +0100
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <t0c04h$f1k$1@dont-email.me>
References: <ygaee3alyb1.fsf@akutech.de> <t0b4m2$3jh$1@dont-email.me>
<ebe8d919-fb4b-4303-9619-8a858ed1f8f7n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 10 Mar 2022 04:51:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c07b610fc713ea6522deaed4b6b28b45";
logging-data="15412"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r8mxjmrSbrFMIKwp/I9sr"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:vzC/tfbmMEEjmpcrFVKqpWVSyLw=
In-Reply-To: <ebe8d919-fb4b-4303-9619-8a858ed1f8f7n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 10 Mar 2022 04:51 UTC

On 10.03.2022 02:25, J Naman wrote:
> 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.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'
>>>

Which OS and shell did you use to execute the subsequent commands?

On Unix systems the awk program argument should be quoted by single
quotes

awk '...'

otherwise $var and $0 are expanded by the shell as shell variables
and awk sees those instead of the passed in parameters.

> Try echo 3 4 | gawk "{print $1.$2}" => 34 ( no 1's or 2's)

Of course no 1s or 2s, because $1. identifies the 1st field and $2
identifies the second field.

> Try echo 3 4 | gawk "{print $1xyz$2}" => 34 (no xyz either)

Of course no xyz, because you concatenate field one, variable xyz,
and field 2, and variable xyz is undefined and thus empty. Define
that variable and you'll see it

$ echo 3 4 | gawk -v xyz=hoho '{print $1xyz$2}'
3hoho4

> echo 3 4 | gawk "{print $1.xyz$2}"=> 34 (no xyz either)

Of course not. Same reason like before.

> echo 3 4 | gawk "{print $1..$2}" two or more decimals gets syntax error

Of course. While 1 and 1. are syntactic correct numbers, 1.. is not.

> See: converting string to numeric ignores alpha, but not 1.., that's syntax
> echo 123usd 456euro | gawk "{print $1+$2}" => 576

Hardly correct. It must result in 579.

The context is arithmetic so from the input fields only the numbers
are taken.

> ref: UsrGuide 6.1.4 Conversion of Strings and Numbers

And what was the point of your post as a reply to our posts?

Janis

Re: what operation is $1.$2 ?

<yga7d92kuff.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1139&group=comp.lang.awk#1139

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.awk
Subject: Re: what operation is $1.$2 ?
Date: Thu, 10 Mar 2022 10:50:44 +0100
Lines: 16
Message-ID: <yga7d92kuff.fsf@akutech.de>
References: <ygaee3alyb1.fsf@akutech.de> <t0b4m2$3jh$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net fh81iGV3XEFm5gywIX3fSgnvgZiguDxwgtEwft/HVbeencc9w=
Cancel-Lock: sha1:TifalR9lYkt8ID1CJf8KkodPBKc= sha1:Bg23V7ILhIV+1VvZ5rtBBMBwwKo=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Thu, 10 Mar 2022 09:50 UTC

* Janis Papanagnou <janis_papanagnou@hotmail.com>
| > 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).

Ouch (i.e. I understand :-)

echo 1st 2nd | awk '{print $1.9}'
1st

echo 1st 2nd | awk '{print $1.9999999999999999999999999999999999}'
2nd

Thanks for the enlightment!
R'

Re: what operation is $1.$2 ?

<b5320545-cb3a-4357-a199-0b38c913b11cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1176&group=comp.lang.awk#1176

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:ac8:5a88:0:b0:2e1:bbda:3b21 with SMTP id c8-20020ac85a88000000b002e1bbda3b21mr23179018qtc.307.1648493589835;
Mon, 28 Mar 2022 11:53:09 -0700 (PDT)
X-Received: by 2002:a25:3b87:0:b0:628:b8a6:c1e7 with SMTP id
i129-20020a253b87000000b00628b8a6c1e7mr24540197yba.422.1648493589691; Mon, 28
Mar 2022 11:53:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 28 Mar 2022 11:53:09 -0700 (PDT)
In-Reply-To: <ygaee3alyb1.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3;
posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
References: <ygaee3alyb1.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b5320545-cb3a-4357-a199-0b38c913b11cn@googlegroups.com>
Subject: Re: what operation is $1.$2 ?
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Mon, 28 Mar 2022 18:53:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 12
 by: Kpop 2GM - Mon, 28 Mar 2022 18:53 UTC

i don't think it's an operation per se

i *think* awk sees your thing as

echo 1 2 | awk '{print $1.$2}'

——> awk '{print ($(1.))($2) }'
——> awk '{print ($(1.0))($2) }'
——> awk '{print ($1)($2) }'

which is a delimiter-less string concat. I'm only guessing here

The 4Chan Teller

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor