Date: Wed, 28 Jul 2021 19:43:40 +0200 From: Michael Gmelin <freebsd@grem.de> To: Michael Butler via freebsd-current <freebsd-current@freebsd.org> Cc: imb@protected-networks.net Subject: Re: awk behaviour? Message-ID: <20210728194340.469c2ee4@bsd64.grem.de> In-Reply-To: <8e1a8e3c-b062-7749-ceab-e500c1ab758e@protected-networks.net> References: <8e1a8e3c-b062-7749-ceab-e500c1ab758e@protected-networks.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 28 Jul 2021 13:29:20 -0400
Michael Butler via freebsd-current <freebsd-current@freebsd.org> wrote:
> I tripped over this while trying to build a local release ..
>
> imb@toshi:/home/imb> pkg --version | awk -F. '{print $$1 * 10000 +
> $$2 * 100 + $$3}'
> 10001
>
> imb@toshi:/home/imb> pkg --version
> 1.17.1
>
> Is this expected?
Yes, as you're using $$ instead of $.
With single dollar sign you'll get the expected value of:
11701
With double dollar you reference the content of the field, so in case
of 1.17.1:
$$1 * 10000 + $$2 * 100 + $$3
is equal to
$1 * 10000 + $17 + $1
Which is:
10000 + 0 + 1
Which equals
10001
-m
>
> imb
--
Michael Gmelin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210728194340.469c2ee4>
