A Unix-like egrep command for Windows, written in Go.
Search files using extended regular expressions with line numbers, context lines, recursive directory search, color-highlighted matches, and multi-pattern support — all the egrep behaviour you already know, working natively on Windows.
Rename the binary to anything you like (eg, search, etc.) — all usage and error messages derive from the executable name automatically.
Requires Go 1.21+.
go install github.com/fermat-tech/winegrep@latestThe binary lands in %USERPROFILE%\go\bin, which should already be on your PATH.
git clone https://github.com/fermat-tech/winegrep.git
cd winegrep
go build -o winegrep.exe .Grab the latest binary from Releases.
winegrep [OPTIONS] PATTERN [FILE...]
winegrep [OPTIONS] -e PATTERN [-e PATTERN...] [FILE...]
winegrep [OPTIONS] -f PATTERNFILE [FILE...]
Reads from stdin if no FILE is given. Glob patterns are expanded automatically (Windows shells don't expand them).
| Flag | Description |
|---|---|
-i |
Ignore case |
-v |
Invert match — print non-matching lines |
-w |
Match whole words only |
-x |
Match whole lines only |
-e PATTERN |
Explicit pattern (may be given multiple times) |
-f FILE |
Read patterns from FILE, one per line |
| Flag | Description |
|---|---|
-n |
Prefix each line with its line number |
-c |
Print only a count of matching lines per file |
-l |
Print only names of files with matches |
-L |
Print only names of files without matches |
-o |
Print only the matched part of each line |
-H |
Always print filename header |
-h |
Never print filename header |
-m N |
Stop after N matching lines |
-q |
Quiet — no output, use exit code only |
| Flag | Description |
|---|---|
-A N |
Print N lines after each match |
-B N |
Print N lines before each match |
-C N |
Print N lines before and after each match |
| Flag | Description |
|---|---|
-r, -R |
Recursively search directories |
| Method | Description |
|---|---|
--color |
Force color output on |
--no-color |
Force color output off |
WINEGREP_COLOR=always|never|auto |
Persistent color preference |
NO_COLOR=1 |
Disable color (no-color.org) |
| Auto (default) | On when stdout is a terminal, off when piped |
Color works on all Windows terminals including the old Command Prompt (cmd.exe).
| Code | Meaning |
|---|---|
0 |
At least one match found |
1 |
No matches found |
2 |
Error (bad pattern, missing file, etc.) |
# Basic search
winegrep "error|warning" app.log
# Case-insensitive with line numbers
winegrep -in "TODO" *.go
# Show 2 lines of context around each match
winegrep -C2 "panic" *.go
# Count matches per file
winegrep -c "func" *.go
# List files containing matches
winegrep -rl "deprecated" src/
# Multiple patterns
winegrep -e "^import" -e "^package" main.go
# Whole-word match
winegrep -w "err" main.go
# Only print the matched text
winegrep -o "v[0-9]+\.[0-9]+\.[0-9]+" CHANGELOG.md
# Search stdin
git log --oneline | winegrep "fix|bug"
# Quiet mode — use exit code in scripts
winegrep -q "FAIL" results.txt && echo "failures found"MIT