Documentation ¶
Overview ¶
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 102
To use GoAWK in your Go programs, see README.md or the "interp" docs.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package interp is the GoAWK interpreter (a simple tree-walker).
|
Package interp is the GoAWK interpreter (a simple tree-walker). |
Package lexer is an AWK lexer (tokenizer).
|
Package lexer is an AWK lexer (tokenizer). |
Package parser is an AWK parser and abstract syntax tree.
|
Package parser is an AWK parser and abstract syntax tree. |