[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Field separators in awk
From: |
Hakon . Hagland |
Subject: |
[bug-gawk] Field separators in awk |
Date: |
Tue, 31 Dec 2013 07:40:28 +0100 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.3.9) |
Hi,
there is a builtin variable RT (
http://www.gnu.org/software/gawk/manual/gawk.html#Auto_002dset ) that
contains the matched text by RS, but there is no similar variable for
FS.
Consider the following case:
http://stackoverflow.com/a/20836890/2173773
In Gnu Awk version 4, the split() function does contain a forth input
argument "seps" that gives access to the matched text by FS.
However, it seems inefficient to call split() on $0 just to obtain the
matched text. (Since the field splitting has already been done by awk).
I would propose either to add a new builtin variable, for instance it
could be called "FT", that contains the separators, or if this is
inefficient (for the common case, where that variable is not used by
the user) to have an option (like I have proposed in a previous mail)
to set FIELDWIDTHS="0" which should make awk skip the field splitting
process all together, and just assign the whole line to $1, and set
NF=1. Then it is up to the user to call split() on $0 if he likes to.
Best regards,
Haakon Haegland
- [bug-gawk] Field separators in awk,
Hakon . Hagland <=