lightgrep
lightgrep is a fast, ergonomic grep-like CLI tool written in Rust. It searches files using regex or string literals, with optional highlighting, line numbers, and recursive searching. It is optimized for performance and can take advantage of multiple CPU cores when processing large files.
Features
-
Search files with regular expressions or string literals
-
Highlight matches with ANSI colors
-
Invert matches to show only non-matching lines
-
Recursive directory search
-
Match multiple literal strings at once using --multiple (e.g., --multiple read text book). For regex, combine patterns into a single expression.
-
Filter by file extension (e.g. .rs, .md)
-
Parallel processing for faster search on large files
Install
)
Build from source
# binary will be in target/release/lightgrep
Usage
lightgrep [OPTIONS] -q <PATTERN> -F [FILE...]
Basic examples:
# search for "TODO" in a specific file
lightgrep TODO -F src/test.txt
# search with a regex (escape shell metacharacters)
lightgrep '\bfixme\b' README.md
# Search all files that have a rs extension for "unsafe"
lightgrep -r --ext rs --query unsafe
# Recursively search and highlight 3 and 5 letter words
❯ lightgrep -E --query "\b[a-zA-Z]{3}\b|\b[a-zA-Z]{5}\b" -r --highlight
# Multiple String Literal Patterns found and highlighted
lightgrep --multiple red blue green --highlight --recursive
# search for "hello" in all .rs files recursively and save results(all lines have at least one match) to output.txt
❯ lightgrep -q hello -r --ext rs >> output.txt
Options:
| Flag | Description | Maps to |
|---|---|---|
-q, --query <PATTERN> |
Query string to search for | Args.query |
--multiple <PATTERN>... |
Multiple literal patterns (conflicts with -E) | Args.multiple |
-i, --ignore-case |
Case-insensitive search | Args.ignore_case |
-F, --file-path <FILE_PATH> |
File or directory to search | Args.file_path |
--invert |
Invert match — print non-matching lines | Args.invert |
-E, --regex |
Treat QUERY as a regex (conflicts with multiple) | Args.regex |
-c, --count |
Only print count of matching lines | Args.count |
-l, --line-number |
Show line numbers for matches | Args.line_number |
-r, --recursive |
Recurse into directories | Args.recursive |
--ext <EXTENSION> |
Filter files by extension (e.g., .rs) |
Args.file_extension |
--highlight |
Highlight matches | Args.highlight |
--help |
Show help message | — |
Notes
)
))
)
License
MIT OR Apache-2.0