This book explains both the awk language and how to run the awk utility. You should already be familiar with basic system commands, such as cat and ls, as well as basic shell facilities, such as input/output redirection and pipes. This book describes the awk language in general and also the particular implementation of awk called gawk. gawk runs on a broad range of Unix systems and has also been ported to Mac OS X, MS-DOS, Microsoft Windows, and VMS.
Many people are familiar with O'Reilly's book on sed and awk, but not this book. If you want to zero in on awk and its capabilities, this is really the better of the two books. It makes an excellent tutorial and reference for system administrators and anyone else that wants to use awk to extract and format text. The following is a description of the book from the context of the table of contents:
Chapter 1. The awk language and gawk - talks about the basics including how to run awk, when you should use awk, and starts you off with a few simple examples.
Chapter 2. Regular expressions - introduces regular expressions in general, and in particular the flavors supported by POSIX awk and gawk.
Chapter 3 Reading Input Files - describes how awk reads your data. It introduces the concepts of records and fields, as well as the getline command. I/O redirection is first described here.
Chapter 4. Printing Output - Besides basic and formatted printing, this chapter also covers I/O redirections to files and pipes, introduces the special filenames that gawk processes internally, and discusses the close built-in function.
Chapter 5. Expressions - describes expressions, which are the basic building blocks of awk patterns and actions.
Chapter 6. Patterns, Actions, and Variables - Each awk statement consists of a pattern with an associated action. This chapter describes how you build patterns and actions, what kinds of things you can do within actions, and awk's built-in variables.
Chapter 7. Arrays in awk - describes how arrays work in awk, how to use array elements, how to scan through every element in an array, and how to remove array elements. It also describes how awk simulates multidimensional arrays, as well as some of the less obvious points about array usage. The chapter finishes with a discussion of gawk's facility for sorting an array based on its indices.
Chapter 8. Functions - describes awk's built-in functions, which fall into three categories: numeric, string, and I/O. gawk provides additional groups of functions to work with values that represent time, do bit manipulation, and internationalize and localize programs.
Chapter 9. Internationalization with gawk - describes the underlying library gawk uses for internationalization, as well as how gawk makes internationalization features available at the awk program level. Having internationalization available at the awk level gives software developers additional flexibility - they are no longer required to write in C when internationalization is a requirement.
Chapter 10. Advanced Features of gawk - a "grab bag" of items that are otherwise unrelated to each other. First, a command-line option allows gawk to recognize nondecimal numbers in input data, not just in awk programs. Next, two-way I/O, discussed briefly in earlier parts of this book, is described in full detail, along with the basics of TCP/IP networking and BSD portal files. Finally, gawk can profile an awk program, making it possible to tune it for performance.
Chapter 11. Running awk and gawk - covers how to run awk, both POSIX-standard and gawk-specific command-line options, and what awk and gawk do with non-option arguments. It then proceeds to cover how gawk searches for source files, obsolete options and/or features, and known bugs in gawk. This chapter rounds out the discussion of awk as a program and as a language. While a number of the options and features described here were discussed in passing earlier in the book, this chapter provides the full details.
Chapter 12. A Library of awk Functions - One valuable way to learn a new programming language is to read programs in that language. To that end, this chapter and Chapter 13 provide a good-sized body of code for you to read, and hopefully, to learn from.
Chapter 13. Practical awk Programs - presents a potpourri of awk programs for your reading enjoyment. The first part describes how to run the programs presented in this chapter. The second presents awk versions of several common POSIX utilities. These are programs that you are hopefully already familiar with, and therefore, whose problems are understood. By reimplementing these programs in awk, you can focus on the awk-related aspects of solving the programming problem.
Chapter 14. Internetworking with gawk - describes gawk's networking features in depth, including a number of interesting examples and the reusable core of a gawk-based web server. The chapter is adapted from "TCP/IP Internetworking with gawk", by Jürgen Kahrs and Arnold Robbins, which is a separate document distributed with gawk.
Thus chapters 1-11 form a tutorial and reference on awk itself, and the last three chapters are additional material for reference or your own personal toolchest of programs. The last chapter is more of a curiosity than anything, since I don't know anyone who does internetworking with gawk, but it is still interesting material. I highly recommend this book if you plan to use awk extensively.