AWK Language Programming/Chapter 1
1 Introduction
If you are like many computer users, you would frequently like to make changes in various text files wherever certain patterns appear, or extract data from parts of certain lines while discarding the rest. To write a program to do this in a language such as C or Pascal is a time-consuming inconvenience that may take many lines of code. The job may be easier with awk.
The awk utility interprets a special-purpose programming language that makes it possible to handle simple data-reformatting jobs with just a few lines of code.
The GNU implementation of awk is called gawk; it is fully upward compatible with the System V Release 4 version of awk. gawk is also upward compatible with the POSIX specification of the awk language. This means that all properly written awk programs should work with gawk. Thus, we usually don't distinguish between gawk and other awk implementations.
Using awk you can:
- manage small, personal databases
- generate reports
- validate data
- produce indexes, and perform other document preparation tasks
- even experiment with algorithms that can be adapted later to other computer languages
1.1 Using This Book
The term awk refers to a particular program, and to the language that you use to tell this program what to do. When we need to be careful, we call the program "the awk utility" and the language "the awk language." The term gawk refers to a version of awk developed as part of the GNU project. The purpose of this book is to explain both the awk language and how to run the awk utility.
The main purpose of the book is to explain the features of awk, as defined in the POSIX standard. It does so in the context of one particular implementation, gawk. While doing so, it will also attempt to describe important differences between gawk and other awk implementations. Finally, any gawk features that are not in the POSIX standard for awk will be noted.
This book has the difficult task of being both tutorial and reference. If you are a novice, feel free to skip over details that seem too complex. You should also ignore the many cross references; they are for the expert user, and for the on-line Info version of the document.
Page:AWK Language Programming.pdf/10 Page:AWK Language Programming.pdf/11 Page:AWK Language Programming.pdf/12