Other Versions (The GNU Awk User’s Guide)
B.5 Other Freely Available awk Implementations ¶
Implementation is the sincerest form of flattery.
— L. Peter Deutsch
It’s kind of fun to put comments like this in your awk code:
// Do C++ comments work? answer: yes! of course
— Michael Brennan
There are a number of other freely available awk implementations.
This section briefly describes where to get them.
The following programs are all written in C:
- Unix
awk Brian Kernighan, one of the original designers of Unix
awk, has made his implementation ofawkfreely available. You can retrieve it from GitHub:git clone https://github.com/onetrueawk/awk bwkawk
This command creates a copy of the Git repository in a directory named bwkawk. If you omit the last argument from the
gitcommand line, the repository copy is created in a directory named awk.To build it, review the settings in the makefile, and then just run
make. Note that the result of compilation is nameda.out; you will have to rename it to something reasonable.See Common Extensions Summary for a list of extensions in this
awkthat are not in POSIXawk.In 2023, Brian Kernighan, along with Al Aho and Peter Weinberger, published a second edition of their book on
awk. Professor Kernighan also maintains a companion web site for the book. A copy of all the book’s programs are available there for download.As a side note, Dan Bornstein has created a Git repository tracking all the versions of BWK
awkthat he could find. It’s available at https://github.com/danfuzz/one-true-awk.mawkMichael Brennan wrote an independent implementation of
awk, calledmawk. It is available under the GPL (see GNU General Public License), just asgawkis.The original distribution site for the
mawksource code no longer has it. A copy is available at https://www.skeeve.com/gawk/mawk1.3.3.tar.gz.In 2009, Thomas Dickey took on
mawkmaintenance. Basic information is available on the project’s web page. The download URL is https://invisible-island.net/datafiles/release/mawk.tar.gz.Once you have it,
gunzipmay be used to decompress this file. Installation is similar togawk’s (see Compiling and Installinggawkon Unix-Like Systems).See Common Extensions Summary for a list of extensions in
mawkthat are not in POSIXawk.mawk2.0In 2016, Michael Brennan resumed
mawkdevelopment. His development snapshots are available via Git from the project’s GitHub page.awkaWritten by Andrew Sumner,
awkatranslatesawkprograms into C, compiles them, and links them with a library of functions that provide the coreawkfunctionality. It also has a number of extensions.Both the
awktranslator and the library are released under the GPL.To get
awka, go to https://sourceforge.net/projects/awka.The project is frozen; no new code changes have been made since approximately 2001.
- Revive Awka
This project, available at https://github.com/noyesno/awka, intends to fix bugs in
awkaand add more features.This project also seems to be frozen; no new code changes have been made since approximately 2021.
pawkNelson H.F. Beebe at the University of Utah has modified BWK
awkto provide timing and profiling information. It is different fromgawkwith the --profile option (see Profiling YourawkPrograms) in that it uses CPU-based profiling, not line-count profiling. You may find it at either ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz or https://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz.-
BusyBox
awk¶ BusyBox is a GPL-licensed program providing small versions of many applications within a single executable. It is aimed at embedded systems. It includes a full implementation of POSIX
awk. When building it, be careful not to do ‘make install’ as it will overwrite copies of other applications in your /usr/local/bin. For more information, see the project’s home page.- The OpenSolaris POSIX
awk The versions of
awkin /usr/xpg4/bin and /usr/xpg6/bin on Solaris are more or less POSIX-compliant. They are based on theawkfrom Mortice Kern Systems for PCs. We were able to make this code compile and work under GNU/Linux with 1–2 hours of work. Making it more generally portable (using GNU Autoconf and/or Automake) would take more work, and this has not been done, at least to our knowledge.The source code used to be available from the OpenSolaris website. However, that project was ended and the website shut down. Fortunately, the Illumos project makes this implementation available. You can view the files one at a time from https://github.com/joyent/illumos-joyent/blob/master/usr/src/cmd/awk_xpg4.
- Libmawk ¶
This is an embeddable
awkinterpreter derived frommawk. For more information, see http://repo.hu/projects/libmawk/.- Mircea Neacsu’s Embeddable
awk¶ Mircea Neacsu has created an embeddable
awkinterpreter, based on BWK awk. It’s available at https://github.com/neacsum/awk. A short overview of how to use it may be found at https://www.codeproject.com/Articles/5264205/Embedding-AWK-in-a-C-program.awkcc¶-
This is an early adaptation of Unix
awkthat translatesawkinto C code. It was done by J. Christopher Ramming at Bell Labs, circa 1988. It’s available at https://github.com/nokia/awkcc. Bringing this up to date would be an interesting software engineering exercise. -
QSE
awk¶ This is an embeddable
awkinterpreter. For more information, see https://code.google.com/p/qse/. The source can be found at https://code.google.com/archive/p/qse/source/default/source.-
wak¶ wak(a permutation of the letters inawk) is a small, mostly POSIX compatible version ofawkwritten in C by Ray Gardner. The source code is available from its Github repository. Some nice articles about its development may be found in the author’s weblog.
The following implementations are written in Go:
goawkThis is an
awkinterpreter written in the Go programming language. It implements POSIXawk, with a few minor extensions. Source code is available from https://github.com/benhoyt/goawk. The author wrote a nice article describing the implementation.AWKgoThis is an
awkto Go translator. It was written by the author ofgoawk. (See the previous entry in this list.) Source code is available from https://github.com/benhoyt/goawk/tree/master/awkgo. The author’s article about it is at https://benhoyt.com/writings/awkgo/.
The following implementations are written in Java:
jawkThis is an interpreter for
awkwritten in Java. It claims to be a full interpreter, although because it uses Java facilities for I/O and for regexp matching, the language it supports is different from POSIXawk. More information is available on the project’s home page.- Hoijui’s
jawk This project, available at https://github.com/hoijui/Jawk, is another
awkinterpreter written in Java. It uses modern Java build tools.
This version is written in Python:
pawk¶-
This is a Python module that claims to bring
awk-like features to Python. See https://github.com/alecthomas/pawk for more information. (This is not related to Nelson Beebe’s modified version of BWKawk, described earlier.)
There are several versions written in Rust:
rust-awkThis program implements a small subset of
awkin Rust. Many features are missing. The code is available at https://github.com/wenley/rust-awk.frawkThis is a language for writing short programs. “To a first approximation, it is an implementation of the AWK language; many common
awkprograms produce equivalent output when passed tofrawk.” However, it has a number of important additional features. The code is available at https://github.com/ezrosent/frawk.zawkThis program is based off of
frawk. The code is available at https://crates.io/crates/zawk.awk-rsThis program simply claims to be “
awkwritten in rust.” It seems to be frozen, with no updates since 2020. The code is available at https://github.com/conradludgate/awk-rs.awk-rsThis program seems to be the most complete and actively maintained of the versions written in Rust. It used to be named
rawkbut is now calledawk-rs. It seems to be different from the other version with the same name. The code is available at https://github.com/pegasusheavy/rawk.
This version is written in Zig:
-
dawk¶ An implementation of
awkin the Zig programming language. See https://codeberg.org/triallax/dawk.
And finally, this tool is written in shell:
-
cppawk¶ Quoting from the web page, “
cppawkis a tiny shell script that is used likeawk. It invokes the C preprocessor (GNUcpp) on the Awk code and calls Awk on the result.” This program may be of use if the waygawk’s@includefacility works doesn’t suit your needs. For more information, see https://www.kylheku.com/cgit/cppawk/.
See also the “Versions and implementations” section of the
Wikipedia article on awk for information on additional versions.
An interesting collection of library functions is available at https://github.com/e36freak/awk-libs.
An interesting collection of gawk extensions is
available https://github.com/su8/gawk-extensions.