Empty FS field splitting behavior limits in POSIX awk versus gawk
23.5K reputation · 06 May 2022, 12:21 UTC
Design goal is a low-traffic, single-pass log aggregation that keeps resident memory bounded while using field splitting and an END block for final totals.
The script relies on awk's line-by-line processing and dynamic FS for record parsing. Associative arrays are required for keyed counts, so memory growth with unique keys is a design constraint. Portability across POSIX awk and common extensions such as gawk is required.
Uncertainty remains about the documented behavior of an empty FS value for consecutive delimiters and multi-character delimiter handling. The specification and extensions diverge on whether empty FS means per-character splitting and how empty fields are preserved.
Does POSIX define empty FS as per-character splitting with empty fields removed? How do POSIX awk and gawk differ in treatment of consecutive delimiters when FS is empty? What portable definition of FS ensures consistent field counts for character-level parsing?