AWK is a powerful but simple scripting language designed for text extraction and processing. Due to its versatility and simple usage, it is a widely-used tool, and there are entire books written on it.
Although it's possible to translate any AWK script into C for faster processing, AWK is often easier to write and debug. Thus, even though a C program may execute faster, it's preferrable to use AWK due to its simplicity and ease of use.
The name AWK comes from its authors Alfred Aho, Peter Weinberger and Brian Kernighan, who developed it in Bell Labs in the 1970's. AWK also serves as a homonym of its mascot, the auk bird.
AWK provides command line users with a variety of functions. You may use a single AWK script to process several files within a pipeline or apply the commands to several files at once. Here are just a few of the features that AWK provides:
In short, AWK can be of immense help to anything that has to do with text processing or data-table manipulation.
There have been a variety of AWK implementations as users started expanding on the language.
For this tutorial, we'll be sticking to
gawk, which is the GNU version of AWK (GNU is simply a suite of open-source utilities - learn about the history of UNIX and GNU). To install
gawk on a Debian-based Linux platform, use the
apt-get package manager.
$ sudo apt-get update $ sudo apt-get install gawk
For RPM based Linux, use
$ sudo yum install gawk
For Mac OS X platform, use homebrew, the package manager for OS X.
$ brew install gawk
One last thing to mention before moving on - to comment in AWK, use either the hashtag symbol (
#) or two forward slashes (
AWK is a difficult programming language to learn, as most of its concepts, syntax and notations are intertwined with each other. Thus, learning one piece of AWK involves having to know some other parts. Due to this, some of the lessons in this tutorial may introduce concepts that will be covered in more detail in a future lesson. So if you see something new and not explained in detail, try your best to understand it and sit tight until we cover it more formally later. Now let's get started!
Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.$ Check price
Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.$$ Check price