Use findstr on Windows to find text in files and command outputs

first_imgUse findstr on Windows to find text in files and command outputs by Martin Brinkmann on May 04, 2018 in Tutorials – Last Update: August 07, 2018 – 19 commentsIf you want to find specific text in files, in a command line output or elsewhere, you may use the findstr command on Windows to do so.Findstr is a built-in tool of the Windows operating system that you may run from the command line to find text in files or in command line outputs.You can use the application to filter command line outputs, search individual files or entire directory structures for files with matching text.Run findstr /? from the command line to display all parameters and options that “Find String” supports.Third-party tools like Notepad++, GGRep, or Everything support finding text in files as well.Using findstrYou can run findstr from the command line or batch files. Open a new command line prompt by tapping on the Windows-key, typing cmd.exe and selecting the result.Useful parameters:/? — display the help text/S — searches the directory and all subdirectories/I — search is not case sensitive/R — use search strings as regular expressions/B — matches patterns at the beginning of lines/P — skip files with non-printable characters/V — print only lines that contain a match/N — print the line numberHere is a list of examples that you may find useful:ipconfig | findstr “192.168” — The command runs ipconfig and returns any result that matches 192.168. Any other result is ignored.netstat | findstr “123.123.123.13” — Runs the netstat command and returns any result that matches the string (in this case the IP address).findstr /c:”windows 10″ windows.txt — Searches the document windows.txt for the string “windows 10″findstr “windows 10” windows txt — Searches for “windows” or “10” in the file.findstr “windows” c:\documents\*.* — Searches any file under c:\documents for the string “windows”.findstr /s /i Windows *.* — Searches every file in the current directory and all subdirectories for the word Windows ignoring letter case.findstr /b /n /r /c:”^ *FOR” *.bas– Returns any line that begins with FOR that are preceded by zero or more spaces. Prints the line number as well.Findstr is a powerful command that you may use to search for strings in files or to filter command line output. You may use it to scan entire directory structures or drives for files that match the selected string or part of it, and to find specified text in command line outputs quickly.Advanced options include returning content that is found at the beginning or end of lines, using regular expressions, or using wildcards.Closing wordsFindstr’s main advantage is that it is a built-in tool that you can run on any Windows machine. It is useful to find text in files quickly but works as a tool to filter the output of command line tools as well.Now you: which program do you use to find text in files?SummaryArticle NameUse findstr on Windows to find text in files and command outputsDescriptionIf you want to find specific text in files, in a command line output or elsewhere, you may use the findstr command on Windows to do so.Author Martin BrinkmannPublisher Ghacks Technology NewsLogo Advertisementlast_img

Leave a Reply

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