1

An Awk Tutorial

Awk is a convenient and expressive programming language that can be applied to a wide variety of computing and data-manipulation tasks. This chapter is a tutorial, designed to let you start writing your own programs as quickly as possible. The remaining chapters show how Awk can be used to solve problems from many different areas; the reference manual in Appendix A describes the whole language in detail. Throughout the book, we have tried to pick examples that you might find useful, interesting, and instructive.

1.1 Getting Started

Useful Awk programs are often short, just a line or two. Suppose you have a file called emp.data that contains three fields of information about your employees: name, pay rate in dollars per hour, ...

Get The AWK Programming Language, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.