DEV Community

Discussion on: AWK an old-school tool today

Collapse
kh40sz3r0 profile image
Sergio Marcial Author • Edited on

That is awesome, however, sometimes I feel like we have taken AWK a little too far or as a teammate would say probably not far enough yet

This is a Golang POSIX AWK variant

GitHub logo benhoyt / goawk

A POSIX-compliant AWK interpreter written in Go

GoAWK: an AWK interpreter written in Go

Documentation GitHub Actions Build

AWK is a fascinating text-processing language, and somehow after reading the delightfully-terse The AWK Programming Language I was inspired to write an interpreter for it in Go. So here it is, feature-complete and tested against "the one true AWK" test suite.

Read more about how GoAWK works and performs here.

Basic usage

To use the command-line version, simply use go install to install it, and then run it using goawk (assuming $GOPATH/bin is in your PATH):

$ go install github.com/benhoyt/goawk@latest
$ goawk 'BEGIN { print "foo", 42 }'
foo 42
$ echo 1 2 3 | goawk '{ print $1 + $3 }'
4
Enter fullscreen mode Exit fullscreen mode

On Windows, " is the shell quoting character, so use " around the entire AWK program on the command line, and use ' around AWK strings -- this is a non-POSIX extension to make…