Advanced Features Summary (The GNU Awk User’s Guide)
From Get docs
Gawk/docs/latest/Advanced-Features-Summary
Previous: Profiling, Up: Advanced Features [Contents][Index]
12.6 Summary
- The
--non-decimal-dataoption causesgawkto treat octal- and hexadecimal-looking input data as octal and hexadecimal. This option should be used with caution or not at all; use ofstrtonum()is preferable. Note that this option may disappear in a future version ofgawk. - You can take over complete control of sorting in ‘
for (indx in array)’ array traversal by settingPROCINFO["sorted_in"]to the name of a user-defined function that does the comparison of array elements based on index and value. - Similarly, you can supply the name of a user-defined comparison function as the third argument to either
asort()orasorti()to control how those functions sort arrays. Or you may provide one of the predefined control strings that work forPROCINFO["sorted_in"]. - You can use the ‘
|&’ operator to create a two-way pipe to a coprocess. You read from the coprocess withgetlineand write to it withprintorprintf. Useclose()to close off the coprocess completely, or optionally, close off one side of the two-way communications. - By using special file names with the ‘
|&’ operator, you can open a TCP/IP (or UDP/IP) connection to remote hosts on the Internet.gawksupports both IPv4 and IPv6. - You can generate statement count profiles of your program. This can help you determine which parts of your program may be taking the most time and let you tune them more easily. Sending the
USR1signal while profiling causesgawkto dump the profile and keep going, including a function call stack. - You can also just “pretty-print” the program.