Grep for Windows

For Unix lovers who find themselves trapped inside a Windows command line window, you may find the findstr command useful. It functions just like grep and has many of the same options. Here are a couple of examples:

C:\>netstat -an | findstr LISTEN
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING

C:\WINDOWS>type wmsetup.log | findstr error
WMC_CopyFile: File 'C:\DOCUME~1\IINFSP04\LOCALS~1\Temp\IXP000.TMP\asferror.dll
' is newer than the installed version. This file will be installed.
Copied file 'C:\DOCUME~1\IINFSP04\LOCALS~1\Temp\IXP000.TMP\asferror.dll' to DllCache.

C:\WINDOWS>findstr error wmsetup.log
WMC_CopyFile: File 'C:\DOCUME~1\IINFSP04\LOCALS~1\Temp\IXP000.TMP\asferror.dll
' is newer than the installed version. This file will be installed.
Copied file 'C:\DOCUME~1\IINFSP04\LOCALS~1\Temp\IXP000.TMP\asferror.dll' to DllCache.

You can get the full listing with findstr /? but some options that are the same between Windows and Unix/Linux are: /v to search for something that is not what you specified and /i to ignore case. (Not sure where that would come into play since case doesn’t usually matter in Windows, but anyway) So, yes, there is a Windows grep...sort of.