Since Windows users are not used to use command-line for smaller things, most of the users don’t know how to find a specific string in files using Windows command-line or even PowerShell. In this article, we will discuss about how to use findstr (equivalent of Grep in Windows) in command prompt and also how to use the find function using PowerShell. Let’s discuss about different scenarios which can be used in real-world situations.

Filter an output of a command Using Command Prompt

If you want to filter the results of a command, you can use | findstr “string_to_find” For example, I mostly use netstat for checking the connections being made on my computer. If I want to check which app or IP address is connected to a specific port, I’ll use the following command: netstat | findstr “imaps”Findstr filtering imaps ports This will show me only secure imap ports opened on my computer.

Search for a specific string inside a single file Using Command Prompt

The command for this purpose is: findstr “string_to_find” “file_name” For example, findstr “reader” “new 1.txt” You can also give full path of the file if it’s not in the same directory as opened in command prompt.find text string in a file

Search for a specific string in a folder using Findstr

You can also specify a folder for finding a specific text string in multiple files. findstr /M “reader” “C:\Users\Usman\Desktop*” This will give a list of all files with full path containing the text string “reader”. If you don’t specify /M, the output will show the exact text string along with the file name where it found the string.Finding a string from folder You can go through all the switches you can use with the command here. This command can be useful in many cases especially when I am creating a log of network activities and have to find a specific thing from the log. What do you do with this filter command “findstr”? Also see:

How to Check Public IP Address Using Command Line In Windows 10/Windows 114 Ways To Open Command Prompt Window in a Folder In Windows 10How To Find And Close Listening Ports In Windows 10How to Start Remote Desktop Connection (mstsc) using Command LineTop 3 Tools to Run Any Process as System or Trustedinstaller in Windows 10