All books
Draft — Work in Progress

AWK Pocket Reference

by Alan Bradley

AWK has lived in every Unix for nearly half a century. Aho, Weinberger, and Kernighan built it at Bell Labs in 1977 to solve a permanent problem — structured text processing — with a minimal, composable design, and that design is why it endures. This pocket reference covers GNU AWK (gawk) with compatibility notes for macOS/BSD: records and fields, pattern–action programs, regular expressions, arrays, built-in and user-defined functions, output redirection and pipes, GNU extensions, debugging, locale, and the one-liners you will keep reaching for. Includes a cheat sheet, a quick reference card, and a task index for jobs you have not done yet but will.

Table of Contents

  1. 1 The AWK Model
  2. 2 Records and Fields
  3. 3 Patterns
  4. 4 Actions and Statements
  5. 5 Variables and Expressions
  6. 6 Regular Expressions
  7. 7 Arrays
  8. 8 Built-in Functions
  9. 9 Output Redirection and Pipes
  10. 10 AWK Programs in Files
  11. 11 User-Defined Functions
  12. 12 Error Handling and Defensive AWK
  13. 13 Practical Recipes
  14. 14 GNU AWK Extensions
  15. 15 Debugging and Profiling
  16. 16 Idioms and Patterns
  17. 17 Locale and Encoding
  18. 18 Gotchas and Edge Cases
  19. 19 AWK vs Other Tools
  20. 20 Cross-Platform Compatibility
  21. A One-Liner Cheat Sheet
  22. B Quick Reference Card
  23. C Task Index