A high-performance string search utility for the command line. Fast, multi-threaded, and grep-compatible.
- Smart algorithm selection (Boyer-Moore, KMP, Two-Way, Shift-Or, Aho-Corasick)
- SIMD acceleration (SSE4.2, AVX2, NEON) and memory-mapped I/O
- Multi-threaded search across CPU cores
- POSIX regular expressions and multiple pattern search
- Recursive directory search with globs, exclusions, and
.gitignoresupport - Grep-compatible context (
-A,-B,-C,-n,-o,-c,-l,-L,-q) - JSON Lines output (
--json) for automation - Colored output
# macOS (Homebrew)
brew install krep
# From source
git clone https://github.com/davidesantangelo/krep.git
cd krep
make
sudo make installRequirements: GCC or compatible C compiler, POSIX system (Linux, macOS, BSD), pthread.
krep [OPTIONS] PATTERN [FILE | DIRECTORY]
krep [OPTIONS] -e PATTERN -e PATTERN ...
krep [OPTIONS] -f FILE # patterns from file (- for stdin)
krep [OPTIONS] -s PATTERN STRING # search in a string instead of a file
cat FILE | krep PATTERNkrep -F "value: 100%" config.ini # fixed string
krep -r "function" ./project # recursive search
krep -r --gitignore "TODO" ./project # respect .gitignore
krep -r --glob '*.c' --exclude '*/vendor/*' "TODO" .
krep -n -C 2 "panic" app.log # line numbers + context
krep -w 'cat' file.txt # whole words only
krep -r -l "DeprecatedAPI" . # list files with matches
krep -q "required" config.ini # quiet existence check
krep --json "needle" ./src/main.c # JSON Lines output
echo 'pattern' | krep -f - target.txt # patterns from stdin-i, --ignore-caseCase-insensitive search-c, --countCount matching lines only-o, --only-matchingPrint only the matched parts-n, --line-numberPrefix lines with line numbers-A, -B, -C NUMContext after, before, or around matches-l, -LFiles with / without matches-q, --quietExit status only-e PATTERNSpecify pattern(s), repeatable-f FILERead patterns from file (-for stdin)-m NUMMax matching lines per file-EPOSIX extended regex-FFixed strings (default)-r, --recursiveRecursively search directories--glob=GLOB,--exclude=GLOBInclude/exclude paths--hiddenInclude hidden files--gitignoreRespect.gitignore--algo=ALGOForce algorithm:auto,bm,kmp,bndm,two-t NUM, --threads=NUMThread count (default: auto)-s STRINGSearch in a string instead of files-w, --word-regexpWhole words only--json, --jsonlJSON Lines output--statsPrint summary to stderr--color[=WHEN]Color control (always,never,auto)--no-simdDisable SIMD-v, --version,-h, --help
Contributions are welcome! Please feel free to submit a Pull Request.
- Davide Santangelo - GitHub
BSD-2 License - see the LICENSE file for details.