Get started with AWK

Tom Deneire
7 min readJun 16, 2022
Photo by Natalia Yakovleva on Unsplash

I have recently (re)discovered AWK through using GoAWK, a POSIX-compliant AWK interpreter written in Go, with CSV support — courtesy of Ben Hoyt. This inspired me to (re)acquaint myself with AWK itself…

What is AWK?

AWK is a true GNU/Linux classic, designed by Alfred Aho, Peter Weinberger, and Brian Kernighan — three of the biggest names in UNIX development and computer science in general. It is a convenient and expressive programming language that can be applied to a wide variety of computing and data-manipulation tasks.

Of course this tutorial is only a brief overview of the basics of AWK. There are several more elaborated tutorials to be found online, as well as the original (and delightfully-terse, as Ben Hoyt calls it) manual The AWK Programming Language written by the designers…

Workflow and structure

Starting out, we need to understand the workflow and program structure of AWK.

An AWK program follows this outline:

  1. execute commands from BEGINblock
  2. read a line from input stream
  3. execute commands on a line or rather ‘record’
  4. repeat if end of file has not been reached
  5. execute commands from ENDblock

--

--

Tom Deneire
Tom Deneire

Written by Tom Deneire

Software engineer, technical writer, IT burnout coach @ https://tomdeneire.be/confident_coding

No responses yet