Exploring the power and sophistication of awk.
I maintain GNU Awk. As part of making releases, I have to create a patch script to convert the file tree of the previous release into the current one. This means writing
rm commands to remove any files that have been removed. This is fairly straightforward using tools like
However, for the 4.1.2 release, I also changed the permissions (mode) on some files. I want to create
chmod commands to update these files’ permission settings as well. This is a little harder, so I decided to write an
awk script that will do this for me.
Let’s take a look at some of the sophistication and control you can achieve using
awk, such as recursion, the use of arrays of arrays, and extension functions for using operating system facilities.
comptrees.awk, uses the
fts() extension function to do the heavy lifting. This function walks file trees, building up a representation of those trees using
gawk‘s arrays of arrays.
Memory Management, Stream Processing, Robot's Google, and Emotive Words
- tigon — an open-source, real-time, low-latency, high-throughput stream processing framework.
- Robo Brain — machine knowledge of the real world for robots. (via MIT Technology Review)
- The Structure and Interpretation of the Computer Science Curriculum — convincing argument for teaching intro to programming with Scheme, but not using the classic text SICP.
Update: the original fourth link to Depeche Mood led only to a README on GitHub; we’ve replaced it with a new link.