GNU awk 4.2 was released and it contains many interesting features. One of them is:
- The FIELDWIDTHS parsing syntax has been enhanced to allow specifying how many characters to skip before a field starts. It also allows specifying '*' as the last character to mean "the rest of the record". Field splitting with FIELDWIDTHS now sets NF correctly. The documentation for FIELDWIDTHS in the manual has been considerably reorganized and improved as well.
I tested the *
thingie and works great to catch the last block into $NF
:
# "*" catches in $NF from the 2+2+1=5th character and until the end
$ awk 'BEGIN {FIELDWIDTHS="2 2 *"} {print $NF}' <<< "1234567890"
567890
However, I cannot see how to use the first part of the feature, which is also described in the GNU Awk's Users Guide → A.6 History of gawk Features → Version 4.2 of gawk introduced the following changes:
FIELDWIDTHS was enhanced to allow skipping characters before assigning a value to a field (see Splitting By Content).
I cannot find an example in the linked section either. Thus, what is this feature exactly doing and how does it work?