| Crates.io | awk-rs |
| lib.rs | awk-rs |
| version | 0.1.0 |
| created_at | 2026-01-02 17:08:11.365318+00 |
| updated_at | 2026-01-02 17:08:11.365318+00 |
| description | A 100% POSIX-compatible AWK implementation in Rust |
| homepage | |
| repository | https://github.com/pegasusheavy/awk-rs |
| max_upload_size | |
| id | 2018894 |
| size | 1,629,604 |
A 100% POSIX-compatible AWK implementation in Rust with GNU AWK (gawk) extension support.
awk-rs aims to be a drop-in replacement for AWK that faithfully implements the POSIX AWK specification while also supporting common GNU AWK extensions. Written in Rust for reliability and performance.
git clone https://github.com/pegasusheavy/awk-rs.git
cd awk-rs
cargo build --release
The binary will be at target/release/awk-rs.
cargo install awk-rs
# Run an AWK program directly
awk-rs 'BEGIN { print "Hello, World!" }'
# Process files
awk-rs '{ print $1 }' file.txt
# Set field separator
awk-rs -F: '{ print $1 }' /etc/passwd
# Set variables before execution
awk-rs -v name="Alice" 'BEGIN { print "Hello, " name }'
# Run program from file
awk-rs -f program.awk input.txt
| Option | Description |
|---|---|
-F fs |
Set field separator (can be a regex) |
-v var=val |
Assign variable before program execution |
-f progfile |
Read AWK program from file |
--posix |
Strict POSIX mode (disable extensions) |
--version |
Print version information |
--help |
Print usage help |
echo "one two three" | awk-rs '{ print $2 }'
# Output: two
awk-rs '{ sum += $1 } END { print sum }' numbers.txt
awk-rs '/error/ { print }' logfile.txt
awk-rs -F: '{ printf "User: %-20s Shell: %s\n", $1, $7 }' /etc/passwd
awk-rs '{ count[$1]++ } END { for (word in count) print word, count[word] }' words.txt
awk-rs aims for 100% compatibility with:
cargo build # Debug build
cargo build --release # Release build
cargo test # Run tests
src/
├── main.rs # CLI entry point
├── lib.rs # Public API
├── error.rs # Error types
├── lexer/ # Tokenization
├── parser/ # Parsing & AST
├── interpreter/ # Execution engine
├── runtime/ # Variables, arrays, fields
└── io/ # Input/output handling
Licensed under either of:
at your option.
Copyright © 2026 Pegasus Heavy Industries LLC
awk-rs has comprehensive test coverage:
cargo test # Run all 639 tests
cargo test --test e2e # E2E tests (412 tests)
cargo test --test gawk_compat # gawk compatibility tests (34 tests)
cargo bench # Run Criterion benchmarks
Contributions welcome! Please read CONTRIBUTING.md for guidelines.
Quick checklist:
cargo fmt and cargo clippySee SECURITY.md for security policy and reporting vulnerabilities.