Skip to content

MARKDOWN SOURCE

Raw
# grust

`grust` is a small Rust grep-style tool for streaming regular-expression search. It reads files one line at a time and supports standard input, recursive directories, line numbers, inverted matches, counts, file listing, and colored matches.

## Setup

Rust `1.98.1` is pinned in `mise.toml`. Install the toolchain and fetch the exact, locked crate versions with:

```sh
mise install
mise run install
```

Run the test suite and strict Clippy checks with `mise run check`.

## Usage

```sh
# Search a file (also works with a pattern and no path to read stdin)
cargo run --locked -- 'error|warning' app.log
cat app.log | cargo run --locked -- -n 'error|warning'

# Search case-insensitively and show line numbers
cargo run --locked -- -in 'timeout' app.log

# Recursively search a directory; color matching text when output is a terminal
cargo run --locked -- -r 'TODO' src/

# Count matching lines, list matching files, or print only matches
cargo run --locked -- -c 'failed' app.log
cargo run --locked -- -l 'panic' logs/
cargo run --locked -- -o '[0-9]+' app.log

# Control color explicitly
cargo run --locked -- --color=always 'error' app.log
```

Paths default to standard input; use `-` as a path to read standard input explicitly. Directories require `-r`/`--recursive`. Symlinks are not followed during recursive traversal. `-o` and `-v` cannot be combined. Exit status is `0` when a match is found, `1` when there are no matches, and `2` on an error.

Useful options: `-i`/`--ignore-case`, `-n`/`--line-number`, `-v`/`--invert-match`, `-r`/`--recursive`, `-c`/`--count`, `-l`/`--files-with-matches`, `-o`/`--only-matching`, `-H`/`--with-filename`, `-h`/`--no-filename`, and `--color=auto|always|never`.

grust

grust is a small Rust grep-style tool for streaming regular-expression search. It reads files one line at a time and supports standard input, recursive directories, line numbers, inverted matches, counts, file listing, and colored matches.

Setup

Rust 1.98.1 is pinned in mise.toml. Install the toolchain and fetch the exact, locked crate versions with:

mise install
mise run install

Run the test suite and strict Clippy checks with mise run check.

Usage

# Search a file (also works with a pattern and no path to read stdin)
cargo run --locked -- 'error|warning' app.log
cat app.log | cargo run --locked -- -n 'error|warning'

# Search case-insensitively and show line numbers
cargo run --locked -- -in 'timeout' app.log

# Recursively search a directory; color matching text when output is a terminal
cargo run --locked -- -r 'TODO' src/

# Count matching lines, list matching files, or print only matches
cargo run --locked -- -c 'failed' app.log
cargo run --locked -- -l 'panic' logs/
cargo run --locked -- -o '[0-9]+' app.log

# Control color explicitly
cargo run --locked -- --color=always 'error' app.log

Paths default to standard input; use - as a path to read standard input explicitly. Directories require -r/--recursive. Symlinks are not followed during recursive traversal. -o and -v cannot be combined. Exit status is 0 when a match is found, 1 when there are no matches, and 2 on an error.

Useful options: -i/--ignore-case, -n/--line-number, -v/--invert-match, -r/--recursive, -c/--count, -l/--files-with-matches, -o/--only-matching, -H/--with-filename, -h/--no-filename, and --color=auto|always|never.