ripgrep: grep like equivalent for Windows

While Windows provides similar capabilities out-of-the-box with PowerShell, most Linux users will undoubtedly be familiar with the grep command:

> grep --help
Usage: grep [OPTION]... PATTERNS [FILE]...
Search for PATTERNS in each FILE.
Example: grep -i 'hello world' menu.h main.c
PATTERNS can contain multiple patterns separated by newlines.

GNU grep home page: <https://www.gnu.org/software/grep/>
General help using GNU software: <https://www.gnu.org/gethelp/>

Fortunately, there is a cross-platform grep like equivalent for Windows (and MacOS/Linux) called ripgrep:

PS> ripgrep --help
ripgrep 14.1.0 (rev e50df40a19)
Andrew Gallant <jamslam@gmail.com>

ripgrep (rg) recursively searches the current directory for lines matching 
a regex pattern. 'By default, ripgrep will respect gitignore rules 
and automatically skip hidden files/directories and binary file

Use -h for short descriptions and --help for more details.

Project home page: https://github.com/BurntSushi/ripgrep

After installing to a location in your PATH, I also recommend creating a symlink so you can use simply type the command grep rather than ripgrep (this may require admin to create depending on your Windows settings):

New-Item -Type SymbolicLink -Path grep.exe -Target rg.exe

Alternatively, you can create a PowerShell alias using Set-Alias command.

Leave a Reply

Your email address will not be published. Required fields are marked *