Last Updated on February 25, 2024 by Mathew Diekhake

I would like to use a Windows equivalent to Grep on Linux. I want to use Windows Grep to find (Skyrim CTDs obviously!) html content within zip files, jar zip files, and PDF documents. And I would like Windows Grep to be free! Resolution: 

The following tutorial demonstrates how to use the grep command in Linux from the Windows command line instead. 

Grep is a command-line utility for searching plain text and is available for the Unix operating system/Linux distributions.

How to Grep in Windows

Windows Grep doesn’t exist, but Windows does have some alternatives that work similarly to grep, namely the findstr command. You can use the findstr from the Command Prompt directly or by opening the Windows Terminal application and choosing to run the Command Prompt shell from there. Moreover, the Windows Grep equivalent for Windows PowerShell is the Select-String command.

How to Use Grep Commands in Windows

You can use the Grep the output of a netstat command, convert it to strings, and Grep a file from the Command Prompt and PowerShell. Here is how to do that:

Note: The following commands will display help for the Windows equivalent to Grep:

For Command Prompt:
C:\> findstr /?

For Windows PowerShell:
PS C:\> get-help Select-String

1. Open the elevated Windows Terminal and then the Command Prompt shell. See this tutorial to open the elevated Windows Terminal window: How to Open Elevated Windows Terminal as Administrator in Windows 11 [Tutorial]

2. Grep the output of a netstat command for a specific port:

For Command Prompt:
C:\> netstat -na | findstr /c:"PORT"

For Windows PowerShell:
PS C:\> netstat -na | Select-String "PORT"

3. Any objects should be convereted to strings by using the Out-String -Stream command:

PS C:\> Get-Alias | Out-String -Stream | Select-String "curl"

4. Grep a file that matches a regular expression:

For Command Prompt:
C:\> findstr /i /r /c:"^SEARCH.*STRING$" file.txt

For Windows PowerShell:
PS C:\> Select-String "^SEARCH.*STRING$" file.txt

Windows Grep Software Download

Additionally, you can download “Windows Grep” programs, such as the PowerGREP app, though it’s not free. As mentioned, the Windows oeprating system doesn’t have an official Windows Grep per se, but some tools choose to use the phrase to make it easy for people to understand what the tool is. PowerGREP is the tool you want to diagnose and solve Skyrim crash with Windows Grep.

There is no Windows Grep software download on Github, but the next best thing would be Grep for Windows on SorceForge.

Windows Grep Examples

$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

$ grep -n root /etc/passwd
1:root:x:0:0:root:/root:/bin/bash
12:operator:x:11:0:operator:/root:/sbin/nologin

$ grep -c false /etc/passwd
7

In conclusion, that is how to use the grep command in Windows.

Related Articles