| Crates.io | lazy-grep |
| lib.rs | lazy-grep |
| version | 0.2.1 |
| created_at | 2025-09-10 18:34:07.908499+00 |
| updated_at | 2025-09-10 18:46:34.999162+00 |
| description | A high-performance, line-oriented command-line tool for searching text with regular expressions. |
| homepage | |
| repository | https://github.com/lazy-toad/rgrep |
| max_upload_size | |
| id | 1832859 |
| size | 25,422 |
lazy-grep is a high-performance, line-oriented command-line tool for searching plain-text data sets for lines that match a regular expression. It is designed as a modern, Rust-based alternative to traditional grep utilities, with a focus on correctness and a rich set of features.
-i flag to perform case-insensitive matching.-w flag to match only whole words.-v flag to select non-matching lines.-B), after (-A), or around (-C) each match.ignore crate to run searches in parallel for maximum speed.--max-depth flag.There are two ways to install lazy-grep.
Once the crate is published on crates.io, you can install it directly using cargo:
cargo install lazy-grep
This will download the source code, compile it, and place the executable in your Cargo binary path, making the lazy-grep command available globally on your system.
If you want to build from the source code, you must have the Rust toolchain installed.
Clone the repository:
git clone <repository-url>
cd lazy-grep
Build the release executable:
cargo build --release
The executable will be available at target/release/lazy-grep.
The basic syntax for lazy-grep is:
lazy-grep [OPTIONS] <PATTERN> <PATH>
Simple search in a file:
lazy-grep "error" log.txt
Case-insensitive search in a directory:
lazy-grep -i "warn" ./logs/
Search for whole words only:
lazy-grep -w "complete" status.log
Show 3 lines of context around each match:
lazy-grep -C 3 "critical" /var/log/
Show 5 lines after each match:
lazy-grep -A 5 "success" results.txt
Invert the search to find lines that DO NOT contain "OK":
lazy-grep -v "OK" healthcheck.log
Performance tests were conducted against the system's standard grep utility. The test file was Herman Melville's Moby Dick (approx. 1.2 MB). The results below show the real time taken for each command.
Note: Benchmarks are indicative and can vary based on hardware and system load.
| Test | Pattern | lazy-grep (real time) |
grep (real time) |
|---|---|---|---|
| 1. Simple String | "whale" |
0.009s | 0.011s |
| 2. Case-Insensitive | "whale" |
0.008s | 0.011s |
3. Regex (\w*ness) |
"\b\w*ness\b" |
0.007s | 0.001s (grep -E) |
lazy-grep demonstrates competitive or superior performance on simple and case-insensitive string searches. The performance of grep on more complex regular expressions is notably faster, likely due to its highly optimized, mature regex engine.
lazy-grep is written entirely in Rust, providing memory safety and high performance.clap crate.regex crate is used for all pattern matching.ignore crate, which provides parallel directory traversal and automatically respects .gitignore files.-B), after (-A), and surrounding (-C) context is implemented manually, with careful state management to handle overlapping or adjacent matches correctly.