Re: awk behaviour?
- In reply to: Michael Butler via freebsd-current : "awk behaviour?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Jul 2021 17:43:40 UTC
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