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-data option causes gawk to treat octal- and hexadecimal-looking input data as octal and hexadecimal. This option should be used with caution or not at all; use of strtonum() is preferable. Note that this option may disappear in a future version of gawk.
  • You can take over complete control of sorting in ‘for (indx in array)’ array traversal by setting PROCINFO["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() or asorti() to control how those functions sort arrays. Or you may provide one of the predefined control strings that work for PROCINFO["sorted_in"].
  • You can use the ‘|&’ operator to create a two-way pipe to a coprocess. You read from the coprocess with getline and write to it with print or printf. Use close() 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. gawk supports 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 USR1 signal while profiling causes gawk to dump the profile and keep going, including a function call stack.
  • You can also just “pretty-print” the program.