goawk: github.com/benhoyt/goawk Files | Directories

Command goawk

Package goawk is an implementation of AWK written in Go.

You can use the command-line "goawk" command or run AWK from your Go programs using the "interp" package. The command-line program has the same interface as regular awk:

goawk [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]

The -F flag specifies the field separator (the default is to split on whitespace). The -v flag allows you to set a variable to a given value (multiple -v flags allowed). The -f flag allows you to read AWK source from a file instead of the 'prog' command-line argument. The rest of the arguments are input filenames (default is to read from stdin).

A simple example (prints the sum of the numbers in the file's second column):

$ echo 'foo 12
> bar 34
> baz 56' >file.txt
$ goawk '{ sum += $2 } END { print sum }' file.txt

To use GoAWK in your Go programs, see README.md or the "interp" docs.

Package Files



internal/strutilPackage strutil provides some miscellaneous string functions.
interpPackage interp is the GoAWK interpreter (a simple tree-walker).
lexerPackage lexer is an AWK lexer (tokenizer).
parserPackage parser is an AWK parser and abstract syntax tree.

Package main imports 12 packages (graph). Updated 2019-01-15. Refresh now. Tools for package owners.