Teach Yourself UNIX Shell Programming in 14 Days

Chapter 12: awk


This chapter discusses the awk programming language. Objectives important to this chapter are:

  • awk syntax
  • math in awk
  • pattern matching in awk
  • looping in awk
  • writing awk programs

The material in the book, up to now, could be considered as preparation for this chapter.

The awk language is a script programming language created by three programmers named Ano, Weinberger, and Kernighan, whose initials spell awk. (We should probably feel lucky they did not call it wak.)

It is capable of doing almost everything we have seen in scripts thus far. In fact, I find it preferable to the other methods, since it uses functions, syntax and logic that are very much like C. For those who are not familiar with C, I offer my apologies, and the notes on C to be found at this site.

For an introduction to awk including exercises, I refer you to Professor Brown's CIT site. The section on awk is about thirty pages, and it is quite good. Rather than compete with him, I ask you to follow this link to his site and be ready to discuss it in class:

Professor Brown's Introduction to awk