#awk #csv #csv-tsv #stdlib #etl #tsv

app zawk

An efficient Awk-like language implementation by Rust with stdlib

39 releases

Uses new Rust 2024

0.8.0 Nov 20, 2026
0.6.9 Nov 7, 2026
0.5.25 Dec 29, 2024
0.5.22 Oct 18, 2024
0.5.2 Mar 18, 2024

#363 in Text processing

Download history 2/week @ 2026-08-07 2/week @ 2026-08-21 1/week @ 2026-08-28 1/week @ 2026-09-11 1/week @ 2026-09-18 1/week @ 2026-09-25 3/week @ 2026-10-02 7/week @ 2026-10-09 6/week @ 2026-10-16 9/week @ 2026-10-23 5/week @ 2026-10-30 6/week @ 2026-11-06 40/week @ 2026-11-13 12/week @ 2026-11-20

64 downloads per month

MIT/Apache and AGPL-3.0-only

7.5MB
103K SLoC

zawk: AWK + stdlib + Rust

zawk is a modern AWK+ language for writing short programs processing textual data. To a first approximation, it is an implementation of the AWK language; many common Awk programs produce equivalent output when passed to zawk.

You might be interested in zawk if you want your scripts to handle escaped CSV/TSV like standard Awk fields, or if you want your scripts to execute faster, or if you want a standard AWK library to make life easy.

zawk overview

Features:

  • CSV/TSV/Excel/Parquet/Avro support
  • Data types: scalars(number, string), associative array, dataframe
  • JSON (-i json, e.g. data.json#$.items to select records with a JSONPath), JSON Lines (-i jsonl), Apache Parquet (-i parquet), Markdown table (-i markdown) and Excel (-i xlsx, the default for .xlsx files; book.xlsx#Sheet2 selects a sheet; mixed with other files, or with -i csv, each workbook is converted to CSV) input
  • Read input files from S3 directly: zawk -i csv '{print $1}' s3://bucket1/demo.csv
  • Read database tables or queries as input (SQLite, MySQL, PostgreSQL), like CSV with a header: zawk '{print $FI["name"]}' 'mysql://root:123456@127.0.0.1:3306/test#people', zawk '{print $1}' 'sqlite://./demo.db#select * from user where age > 30'. With --null '\N', NULL is told apart from '': isnull($2), and -o jsonl/parquet write it as null
  • High performance
  • gawk mostly compatible
  • A standard library: text, math, datetime, crypto, parser, encode/decode, ID, KV, SQLite/MySQL, Redis/NATS/Kafka etc.
  • DataFrames without new syntax: df_* functions on string handles for grouping, joins, multi-key sorts and pivots, e.g. END { d = df_read("orders.csv"); df_print(df_sort(df_group(d, "city", "sum(amount) as total"), "total desc"), "table") }. Tables are loaded from any input format (CSV, JSON, Parquet, Excel, databases, S3, ...), collected in the main loop with df_append(d, $1, $2), written with df_write(d, "out.parquet"), and turned back into awk arrays with df_col/df_row (see DataFrames)
  • i18n support: length("你好Hello") # 7, substr("你好Hello", 1, 2) # 你好
  • Load awk script from URL
  • Run the first ```awk (or zawk/gawk) code block of Markdown: zawk -f notes.md, or a Markdown program text such as an LLM answer: zawk -i csv -H "$(zawk llm -i csv -H demo.csv 'how many adults?' | llm)" demo.csv
  • Field list shorthand: a command-line program that is only a comma-separated list of two or more fields prints them, e.g. zawk '$1,$3' is zawk '{ print $1,$3 }'. A single field such as zawk '$2' keeps the standard awk meaning (print records whose $2 is non-empty/non-zero).
  • awk file help support
  • gawk's switch statement: switch ($1) { case 1: ...; break; case /^a/: ...; break; default: ... }
  • local variable: { local a = 0; ... }
  • match expression: level = match $3 { /^E/ => "error", "warn" | "W" => "warn", /(\d+)ms/ as m => m[1] > 1000 ? "slow" : "ok", _ => "info" }; numbers compare as numbers (3 => ... matches 3.0), _ is the default, and no match without _ gives "".
  • String interpolation with f-strings: f"SELECT * FROM {table} WHERE id = {$1}". A placeholder is any expression ({NR+1}, {toupper($2)}, {a[\"k\"]}), optionally with a Python-style format spec: {price:.2f}, {name:>10}, {n:05d}, {s:*^9}, {ratio:.1%}, {total:,}, {amount:_.2f}; {{ and }} are literal braces.
  • Raw string literals, like Rust's: r"C:\Program Files\Rust", backslashes are not escapes; add #s to include quotes: r#"say "hi""#. Handy for paths and dynamic regexes: $0 ~ r"\d+\.\d+".

The info subdirectory has more in-depth information on zawk:

  • Overview: what zawk is all about, how it differs from Awk.
  • Types: A quick gloss on zawk's approach to types and type inference.
  • Parallelism: An overview of zawk's parallelism support.
  • Benchmarks: A sense of the relative performance of zawk and other tools when processing large CSV or TSV files.
  • Standard Library: A standard library by zawk, including exciting functions that are new when compared with Awk.
  • FAQ: FAQ about zawk.

zawk/frawk is dual-licensed under MIT or Apache 2.0.

Installation

Mac with Homebrew:

$ brew install --no-quarantine linux-china/tap/zawk
$ sudo xattr -r -d com.apple.quarantine $(readlink -f $(brew --prefix zawk))

or install by cargo-binstall:

$ cargo binstall zawk

You will need to install Rust. If you have not updated rust in a while, run rustup update nightly (or rustup update if building using stable).

Building a Binary

With those prerequisites, cloning this repository and a cargo build --release or cargo install --path <zawk repo path> will produce a binary that you can add to your PATH if you so choose:

$ cd <zawk repo path>
$ cargo install --path .

zawk is now on crates.io, so running RUSTFLAGS="-C target-feature=+aes,+sse2" cargo install zawk with the desired features should also work.

SIMD fast paths (SSE2/AVX2) are selected at runtime, so the default build runs on any CPU of the target architecture. To additionally optimize the rest of the code for the CPU you are building on, use:

$ RUSTFLAGS="-C target-cpu=native" cargo install zawk

The resulting binary may crash with SIGILL on other machines, so do not distribute it.

Bugs and Feature Requests

zawk has bugs, and many rough edges. If you notice a bug in zawk, filing an issue with an explanation of how to reproduce the error would be very helpful. There are no guarantees on response time or latency for a fix. No one works on zawk full-time. The same policy holds for feature requests.

Credits

Thanks to Eli Rosenthal's frawk. zawk is based on frawk. Without frawk, there would be no zawk.

References

Dependencies

~185MB
~3M SLoC