Advanced Processing with awk

awk lets you process text in a number of ways. You can use it to extract fields in a file, calculate totals, and even change the order of the output of a file. awk is a command-line utility, but it’s also a scripting language with loops, variables, and conditionals.

Much like sed, awk works slightly differently depending on the version installed on your operating system. On Ubuntu, the awk command that ships out-of-the-box is missing a few features, so install a more full-featured version before moving on:

 $ ​​sudo​​ ​​apt​​ ​​install​​ ​​gawk

Let’s explore awk by using some data from the 2010 U.S. Census that shows population by state. You can find the full dataset in the book’s code download, but you’ll use ...

Get Small, Sharp Software Tools 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.