When processing text files, the awk language is ideal for handling data extraction, reporting, and data-reformatting jobs. This practical guide serves as both a reference and tutorial for POSIX-standard awk and for the GNU implementation, called gawk. This book is useful for novices and awk experts alike.
In this thoroughly revised edition, author and gawk lead developer Arnold Robbins describes the awk language and gawk program in detail, shows you how to use awk and gawk for problem solving, and then dives into specific features of gawk. System administrators, programmers, webmasters, and other power users will find everything they need to know about awk and gawk. You will learn how to:
Format text and use regular expressions in awk and gawk
Process data using awk's operators and built-in functions
Manage data relationships using associative arrays
Define your own functions
"Think in awk" with two full chapters of sample functions and programs
Take advantage of gawk's many advanced features
Debug awk programs with the gawk built-in debugger
Extend gawk by writing new functions in C or C++
This book is published under the terms of the GNU Free Documentation License. You have the freedom to copy and modify this GNU manual.
Royalties from the sales of this book go to the Free Software Foundation and to the author.
Arnold Robbins is a professional programmer and technical author who has worked with Unix systems since 1980 and has been using AWK since 1987. As a member of the POSIX 1003.2 balloting group, he helped shape the POSIX standard for AWK. Arnold is currently the maintainer of gawk and its documentation. He is coauthor of the sixth edition of O'Reilly's Learning the vi Editor.
The animal on the cover of Effective awk Programming, Fourth Edition, is a great auk, a powerful symbol of nineteenth-century European and American arrogance toward nature. In using great auks as food and for their oil, and later collecting specimens for the kind of trivial display so popular with the inhabitants of mansions in Victorian England, mankind showed no mercy. No care was taken to effectively manage the few delicate populations as sustainable resources, much less treat the great auk as a living species worthy of respect. In 1844, sailors working for a British collector killed thelast two great auks and stole their incubating egg on an island off the coast of Iceland.The original penguins, great auks were large, black and white, flightless seabirds with pronounced, bent, orange beaks. The auks nested for three to four weeks each spring on craggy islands in the North Atlantic. When not nesting with their lifelong mates, great auks swam the seas in extended-family groups, occasionally deep-sea diving for large fish. Sixteenth-century sailors who exploited nestingpopulations for food during long voyages called the birds penguins, a name they also gave to the smaller-beaked seabirds of the Southern Hemisphere that still exist today.