Sujet : Re: Breaking a table of record rows into an array
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.awkDate : 14. Mar 2024, 01:22:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240313171753.836@kylheku.com>
References : 1 2 3 4 5 6 7 8
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-13, Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
That describes what happens if NF is modified by assignment, but I don't
see that it implies that such an assignment is allowed.
Here is a problem. In numerous implementations, when you set NF, not
only does that set the number of fields, but $0 is recomputed.
So instead of $1=$1 you can use NF=NF.
$ echo '1 2 3 4' | awk -v OFS=: '{ NF=NF; print $0; }'
1:2:3:4
$ echo '1 2 3 4' | awk -v OFS=: '{ NF=2; print $0; }'
1:2
We can continue to infer that if setting NF causes certain fields to
exist, and not others, then $0 must be reconstituted accordingly,
just like when a field is assigned, according to the idea that Awk
implements a kind of "reactive programming" paradigm whereby $0
and the fields are kept in sync.
But that's going a little unconfortably far on the proverbial limb,
without assurance from the text.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca