Programs Summary (The GNU Awk User’s Guide)
From Get docs
Gawk/docs/latest/Programs-Summary
Next: Programs Exercises, Previous: Miscellaneous Programs, Up: Sample Programs [Contents][Index]
11.4 Summary
- The programs provided in this chapter continue on the theme that reading programs is an excellent way to learn Good Programming.
- Using ‘
#!
’ to makeawk
programs directly runnable makes them easier to use. Otherwise, invoke the program using ‘awk -f …
’. - Reimplementing standard POSIX programs in
awk
is a pleasant exercise;awk
’s expressive power lets you write such programs in relatively few lines of code, yet they are functionally complete and usable. - One of standard
awk
’s weaknesses is working with individual characters. The ability to usesplit()
with the empty string as the separator can considerably simplify such tasks. - The examples here demonstrate the usefulness of the library functions from A Library of awk Functions for a number of real (if small) programs.
- Besides reinventing POSIX wheels, other programs solved a selection of interesting problems, such as finding duplicate words in text, printing mailing labels, and finding anagrams.