Day 27: Learning awk
Has Got Me Thinking
I finished covering the basics with sed
and moved on to learning the basics of awk
. So far it still isn’t entirely clear. It feels like there is some overlap between sed
and awk
. At this point I can’t decide whether I like it or not but I’ll keep going.
TLDR;
Okay, so here are the highlights of what I did:
- I continued to study and write notes on the
sed
program. I have a baseline understanding of it but I haven’t found the opportunity to use it yet. At this point though it seems like everything has some connection to the AT&T Bell Laboratories. - I started writing notes on the
awk
program. The GNU Manual is very rich in information. It’s almost overwhelming.
My awk
Notes so far:
The
awk
program allows a user to select particular records in a file and perform operations upon them. These notes cover the GNU Awk program or ‘GAWK’. At the time of writing these notes I have version 4.1. The Manual reference I have included is based on version 5.1. Therefore, there may be some differences between the two.
It seems that there is a difference between
awk
andgawk
. These notes will be coveringawk
. Once I learn the differences betweenawk
andgawk
I will be covering that as well.
Apparently… The GNU implementation of
awk
is calledgawk
; if you invoke it with the proper options or environment variables, it is fully compatible with the POSIX1 specification of theawk
language and with the Unix version ofawk
maintained by Brian Kernighan. This means that all properly writtenawk
programs should work withgawk
. So most of the time, we don’t distinguish betweengawk
and otherawk
implementations.
he awk language has evolved over the years. Full details are provided in The Evolution of the awk Language. The language described in this Web page is often referred to as “new awk.” By analogy, the original version of awk is referred to as “old awk.”
On most current systems, when you run the awk utility you get some version of new awk.4 If your system’s standard awk is the old one, you will see something like this if you try the following test program:
Conclusion
That’s all for today. If you are interested in the MIT course you can check out the video lecture I’m currently going through. The lecture is helpful but isn’t sufficient by itself. Anyways, until next time PEACE!