Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

. (dot) as concatenation operator?

45 views
Skip to first unread message

Kenny McCormack

unread,
Aug 4, 2016, 4:29:56 AM8/4/16
to
I've never heard of this before, but it seems to work.

I was watching a YouTube vid about AWK, and it showed the following syntax:

{ print $1.$2 }

which seems to do the exact same thing as if the dot weren't there.

It seems to work. Is this standard?

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain in
compliance with said RFCs, the actual sig can be found at the following web address:
http://www.xmission.com/~gazelle/Sigs/BestCLCPostEver

pop

unread,
Aug 4, 2016, 6:14:31 AM8/4/16
to
Kenny McCormack wrote on 8/4/2016 3:29 AM:
> I've never heard of this before, but it seems to work.
>
> I was watching a YouTube vid about AWK, and it showed the following syntax:
>
> { print $1.$2 }
>
> which seems to do the exact same thing as if the dot weren't there.
>
> It seems to work. Is this standard?
>
I think you are seeing the .(dot) concatenated to the 1 in $1 making it
$1.0 which is the same as $1 - the .(dot) will not work as concatenation
under other conditions. try it with:
{ x=1; print $x.$2 }
won't work... but {x=1; print $x $2} works...

--
Best wishes
pop->Mark

pop

unread,
Aug 4, 2016, 6:23:08 AM8/4/16
to
as does:
{x=1; print $x$2}

Kenny McCormack

unread,
Aug 4, 2016, 10:05:57 AM8/4/16
to
In article <nnv4i6$rc6$1...@pop.motzarella.org>, pop <p_...@hotmail.com> wrote:
>Kenny McCormack wrote on 8/4/2016 3:29 AM:
>> I've never heard of this before, but it seems to work.
>>
>> I was watching a YouTube vid about AWK, and it showed the following syntax:
>>
>> { print $1.$2 }
>>
>> which seems to do the exact same thing as if the dot weren't there.
>>
>> It seems to work. Is this standard?
>>
>I think you are seeing the .(dot) concatenated to the 1 in $1 making it
>$1.0 which is the same as $1...

I don't think your analysis stands up. If you work though some other
cases, it becomes hard to come up with a consistent narrative.

It is pretty clear that this is not some as-of-yet-unknown-to-me feature,
but rather some sort of parsing quirk. It is (obviously) not just a
synonym for normal concatenation.

But do note that the above-quoted line:

{ print $1.$2 }

does indeed do the same thing as:

{ print $1 $2 }

which is, obviously, not the same as:

{ print $1 }

unless $2 is empty/null.

Also, see:

https://www.youtube.com/watch?v=az6vd0tGhJI

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain in
compliance with said RFCs, the actual sig can be found at the following web address:
http://www.xmission.com/~gazelle/Sigs/ForFoxViewers

Janis Papanagnou

unread,
Aug 4, 2016, 10:39:48 AM8/4/16
to
On 04.08.2016 10:29, Kenny McCormack wrote:
> I've never heard of this before, but it seems to work.
>
> I was watching a YouTube vid about AWK, and it showed the following syntax:
>
> { print $1.$2 }
>
> which seems to do the exact same thing as if the dot weren't there.
>
> It seems to work. Is this standard?

It doesn't work with GNU awk...

$ awk '{ x=$1; y=$2; print x.y }'
awk: cmd. line:1: { x=$1; y=$2; print x.y }
awk: cmd. line:1: ^ syntax error
$ awk '{ x=$1; y=$2; print x . y }'
awk: cmd. line:1: { x=$1; y=$2; print x . y }
awk: cmd. line:1: ^ syntax error
$ awk '{ print $1 . $2 }'
awk: cmd. line:1: { print $1 . $2 }
awk: cmd. line:1: ^ syntax error
$ awk '{ print $(1).$2 }'
awk: cmd. line:1: { print $(1).$2 }
awk: cmd. line:1: ^ syntax error

It's no concatenation operator. (Ignore unreliable obscure web sources.)

To me pop's explanation makes sense...

$ awk '{ print $(1.)$2 }'
# no error


Janis

Kenny McCormack

unread,
Aug 4, 2016, 10:46:50 AM8/4/16
to
In article <nnvk3j$bb4$1...@news-1.m-online.net>,
Janis Papanagnou <janis_pa...@hotmail.com> wrote:
>On 04.08.2016 10:29, Kenny McCormack wrote:
>> I've never heard of this before, but it seems to work.
>>
>> I was watching a YouTube vid about AWK, and it showed the following syntax:
>>
>> { print $1.$2 }
>>
>> which seems to do the exact same thing as if the dot weren't there.
>>
>> It seems to work. Is this standard?
>
>It doesn't work with GNU awk...

It does.

All testing done with GAWK.

--
Marshall: 10/22/51
Jessica: 4/4/79

Janis Papanagnou

unread,
Aug 4, 2016, 10:54:17 AM8/4/16
to
In your posting I see just the one quoted line of a test. The result
is explainable, as pop already did. If you have other more expressive
tests please post them so that we have something to discuss.

Requirements for a concatenation _operator_ go beyond such coincidence
that can be explained by other means; I posted a couple test cases (that
you stripped here) that shows that there is no dot as concatenation
operator in awk.

Janis

Ed Morton

unread,
Aug 4, 2016, 11:38:43 AM8/4/16
to
On 8/4/2016 3:29 AM, Kenny McCormack wrote:
> I've never heard of this before, but it seems to work.
>
> I was watching a YouTube vid about AWK, and it showed the following syntax:
>
> { print $1.$2 }
>
> which seems to do the exact same thing as if the dot weren't there.
>
> It seems to work. Is this standard?
>

3. = 3.0 = 3
$1. = $(1.0) = $1

Get it?

Ed.

Ed Morton

unread,
Aug 4, 2016, 11:51:34 AM8/4/16
to
On 8/4/2016 9:05 AM, Kenny McCormack wrote:
> In article <nnv4i6$rc6$1...@pop.motzarella.org>, pop <p_...@hotmail.com> wrote:
>> Kenny McCormack wrote on 8/4/2016 3:29 AM:
>>> I've never heard of this before, but it seems to work.
>>>
>>> I was watching a YouTube vid about AWK, and it showed the following syntax:
>>>
>>> { print $1.$2 }
>>>
>>> which seems to do the exact same thing as if the dot weren't there.
>>>
>>> It seems to work. Is this standard?
>>>
>> I think you are seeing the .(dot) concatenated to the 1 in $1 making it
>> $1.0 which is the same as $1...
>
> I don't think your analysis stands up. If you work though some other
> cases, it becomes hard to come up with a consistent narrative.

No it doesn't, pop is correct. If you post the examples that are confusing you
we can explain them to you.

Ed.
0 new messages