Monday, September 30, 2019

Windows command line string search

If you find yourself using the Windows command line and are overwhelmed by the number or rows a command returns, you can filter the output so it only returns rows that match your criteria.  To do this you use the findstr command:  (https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr)

To match on a simple string you use the /C switch and pass the string

example:  netstat -oan | findstr /C:"abcd"

this will return all rows with "abcd" in it

If you want to be more fancy you can use the switch /R and it will evaluate the string you are searching for as a regular expression.