rgrep is a fast, parallel, grep-like search tool written in Rust.
It’s designed as a learning project and to showcase efficient text processing, parallel file and directory traversal and a realistic, user-friendly command-line interface
The goal is not to be a drop-in replacement for grep, but to support a solid, practical subset of functionality.
- Search for a pattern in one or more files, directories, or standard input.
- Pattern syntax:
- Regex by default
- Fixed string optional mode
- Streams input: no need to load whole files into memory.
rgrep PATTERN [PATH...]
# If no PATH is given, rgrep reads from stdin.-
-h,--helpShow help message and exit. -
--versionShow version information and exit. -
-i,--ignore-caseCase-insensitive matching. -
-F,--fixed-stringsTreat the pattern as a literal string instead of a regular expression. -
-w,--word-regexpMatch only whole words. -
-x,--line-regexpMatch only whole lines (the entire line must match the pattern). -
-v,--invert-matchSelect non-matching lines (inverse search).
-
-r,--recursiveRecursively search directories given inPATH. -
--include=GLOBOnly search files whose names match the given glob (e.g.--include='*.rs'). -
--exclude=GLOBSkip files whose names match the given glob (e.g.--exclude='*.log'). -
--hiddenInclude hidden files/directories (by default they may be skipped).
-
-n,--line-numberShow line numbers with matching lines. -
-l,--files-with-matchesPrint only the names of files containing matches. -
-c,--countPrint the number of matching lines per file instead of the lines themselves. -
-q,--quiet,--silentDo not print matches; exit with status:0if a match is found1if no matches are found2on error
-
--with-filenameAlways show the filename prefix (even if a single file or stdin). -
--no-filenameNever show the filename prefix (useful when piping into other tools).
-
-A NUM,--after-context=NUMPrintNUMlines after each matching line. -
-B NUM,--before-context=NUMPrintNUMlines before each matching line. -
-C NUM,--context=NUMPrintNUMlines of context before and after each match.
-
-j N,--jobs=NNumber of worker threads to use.N> 0: use exactlyNthreads.- If omitted: automatically choose a sensible default (e.g. number of CPU cores).
-
--no-parallelForce single-threaded mode (useful for debugging and performance comparison). -
--statsPrint simple performance statistics after the search:- Number of files scanned
- Number of lines processed
- Number of matches found
- Approximate runtime and throughput
-
--color[=WHEN]Colorize matching text.WHENcan be:auto(default): color only when output is a terminalalways: always use colornever: never use color
0– At least one match was found.1– No matches were found.2– An error occurred (e.g. invalid regex, unreadable file).
Search for “error” in a single file:
rgrep "error" app.logCount matches from standard input:
echo -e "foo\nbar\nfoo" | rgrep -c fooRecursive, case-insensitive search in a source tree:
rgrep -ri "panic" src/Show line numbers and some context around matches:
rgrep -n -C 2 "TODO" src/Literal search (no regex) and just count matching lines:
rgrep -F -c "GET /health" logs/*.logParallel search using 8 worker threads:
rgrep -j 8 "timeout" /var/logOnly show filenames of files that contain “unsafe”:
rgrep -rl "unsafe" src/Search only Rust files, skipping everything else:
rgrep -r --include="*.rs" "Result<" .Build and run from the workspace root:
cargo build --release
# or run directly
cargo run --release -- --help # note the extra `--` to pass args to rgrep
cargo run --release -- "panic" src/- GitHub release binaries (recommended for users): download the archive for your platform from the GitHub Releases page, unpack, and place
rgrepon yourPATH. - Cargo install from the repo:
cargo install --git https://github.com/DennisLent/rgrep --branch main
To compare rgrep with grep on a large codebase, there is a helper script that benchmarks common workloads (counting matches, listing files with matches, word searches, etc.) on a clone of the Linux kernel:

