For the uninitiated, a pattern searching tool like findstr may seem useless. But when dealing with system-generated log files or command line outputs containing hundreds of lines of text, findstr is just the tool you need.

Users of a Linux operating system would be already familiar with the incredible utility of the Grep command, and findstr fulfills a similar role in Microsoft Windows. You can combine it with other commands using pipes or just run it directly to parse through multiple text files. Let’s look at how findstr works with a few examples.

tools review, microsoft

Using the Findstr Command

The basic syntax is simple – findstr , where is the pattern to search for, and is the address of the file to search in. Open Command Prompt and give it a try.

findstr SFC example1.txt

This command will find and output all lines containing the search string SFC. Note that by default, findstr is case-sensitive, so any mentions of SFC will not be matched.

tools review, microsoft


You can further customize how findstr works by including optional parameters. Switches like /B or /I modify the behavior of findstr, imposing additional conditions on the search. For example:

findstr /I SFC example1.txt

Including /I as a parameter makes the search case insensitive, allowing all mentions of the term to match, regardless of their capitalization. You can find the list of all parameters of findstr in the official Microsoft docs.

tools review, microsoft

Optional Patterns

Parameters aren’t the only way you can customize findstr. Enclosing the in quotes, for example, allows you to specify multiple patterns, giving you a match if any of the text strings are found.

findstr “SFC DISM” example1.txt

The above will return matching lines containing either of the terms. This makes it useful when looking for a mention for an item with different names.

tools review, microsoft

Regular Expressions

Findstr is capable of searching through multiple files. Changing to a regular expression makes the command look for the specified pattern in all files that match.

findstr SFC *.txt

Using the wildcard character matches the regex to all text files in the current directory and its subdirectories. The results are likewise segregated by filenames, letting you see which line originated from which file.

tools review, microsoft


Like most cmd commands, findstr can also be used on the output of other commands. Just add a pipe after the end of the target command and invoke findstr without a .

dir | findstr .txt

This runs a findstr search on the output of the dir command, returning the file list ending with .txt. Of course, this particular example is useless in practice since dir can already locate files of the same type with a regular expression.

tools review, microsoft

One can also take the longer route of redirecting the output to a text file and then using findstr on the text file, but it is easier to cut the middleman.

Applications of Findstr in Windows

The obvious uses of findstr are readily apparent from the syntax alone. You can look for text files with a specific text string or see if a particular string is contained in a file.

This, while theoretically useful, rarely sees use outside of rare cases. In the age of cloud services like Google Docs, most people no longer have many text files.

The actual applications of findstr are a bit more subtle and involve more powerful results. Here are some of the more interesting examples.

Finding Specific Types of Files

The dir command already includes the option to search for filenames using regular expressions. But with findstr, you can search for files sharing other attributes, such as the time or date of creation.

Suppose an error occurred at 06:43 PM, and you want to locate all log files created at that time. With the dir command alone, you will have to manually sift through the results or get all the log files and compare them. Using findstr, this becomes a simple command.

dir | findstr 06:43

tools review, microsoft

You can try the same trick to find files created on a particular date or get a list of directories.

dir | findstr DIR

tools review, microsoft

Filtering Network Information With Netstat

Netstat is a handy Windows command that gives you all the information about your computer’s network connections—too much information, which is where findstr comes in.

Piping netstat’s output into findstr lets you search for connections with specific properties. For example, this is how you can get a list of all established connections.

netstat | findstr ESTABLISHED

tools review, microsoft

This trick is useful when diagnosing network issues. You can even use findstr with an application PID to find all connections opened by a particular process.

netstat -o | findstr 13120

tools review, microsoft

Obtaining Specific IP Addresses

The ipconfig command lets you view details of all network interfaces of the systems, including IP addresses. You can use findstr to extract a particular type of IP address without having to scroll through the whole thing.

ipconfig | findstr Temporary

tools review, microsoft

You can extend this method to obtain any information from ipconfig, from the subnet masks to gateway addresses.

Analyzing Script Files

Whichever programming language you code in, the script files are ultimately just text. This means you can use findstr to analyze scripts and retrieve specific sections without scouring through the whole code.

Say we want to see how the if statement has been used in a particular script. We can use the following command:

findstr if script.ahk

tools review, microsoft

Not only will this display the lines using the if statement, but it will also show us the expressions used. You can also include the /N parameter to display the line numbers, which is very handy for script files.

findstr /N if script.ahk

tools review, microsoft

Is Findstr Worth Using?

The main difficulty in navigating the command line interface is the amount of text one needs to sift through. Findstr is an essential tool for extracting useful information and filtering out junk.

Since all terminal commands give a text-based output, findstr can always be used to locate the relevant data. From troubleshooting network issues to finding the correct files, every action is made more efficient with findstr.

Even outside of its synergy with other commands, findstr is helpful for its ability to traverse the contents of text files. You can find specific errors in machine-generated log files or retrieve sections of code in a complex script.

In short, findstr is an indispensable tool in the arsenal of any advanced Windows user, especially one intending to get familiar with the command line interface.


How to get Torkoal Coal in Pokémon Scarlet and Violet

Screenshot by Gamepur Pokémon Scarlet and Violet took the crafting mechanic from Legends Arceus and improved upon it. Now, you can use crafting materials to make TMs at TM Machines around the Paldea region. This allows you to teach your pokémon new moves. Torkoal Coal is one of the ...

View more: How to get Torkoal Coal in Pokémon Scarlet and Violet

NieR: Automata Ver1.1a Anime Reveals Lily With New Trailer & Artwork

Today Aniplex released another trailer of the upcoming NieR: Automata Ver1.1a anime, alongside a new piece of artwork. This one is rather special, as it introduces a fairly obscure character, Lily, a resistance fighter who will be more familiar to fans of the manga and the stage play. Apparently, she’s ...

View more: NieR: Automata Ver1.1a Anime Reveals Lily With New Trailer & Artwork

This week in Canadian telecom: Black Friday deals and Rogers-Shaw hearing [Nov. 19-25]

Executives at Rogers confirmed they'll receive hefty bonuses once the merger closes

View more: This week in Canadian telecom: Black Friday deals and Rogers-Shaw hearing [Nov. 19-25]

Share how to use the shortcut to switch from MAC to Win

If you want to use the keyboard shortcut to switch from MAC to Windows still don’t know how to use it. Please read the following article of our sharing about the shortcut to switch from Win to Mac you should find out. 1. Option/Alt key – Shortcut to switch from ...

View more: Share how to use the shortcut to switch from MAC to Win

OnePlus 11 Color Variants Tipped Ahead Of Launch

OnePlus 11 is yet to launch, however, it is slated to launch soon. It goes without saying, it’s a flagship phone and there’s a lot of speculations and leaks about the same. According to a reputed leakster, the OnePlus 11 will arrive in two major colors and here’s the ...

View more: OnePlus 11 Color Variants Tipped Ahead Of Launch

Crypto Marketers Search for a New Sales Pitch After FTX Crisis

As the FTX contagion continues, crypto marketers are scrambling to sell a more appealing vision of the industry—and reassure a wary public.

View more: Crypto Marketers Search for a New Sales Pitch After FTX Crisis

How to Reset Network Settings on Samsung

Thomas Andre Fure/ You can quickly reset your Samsung phone’s network settings by opening the Settings app and then tapping General Management > Reset > Reset Network Settings > Reset Settings > Reset. If you’re experiencing issues with your Wi-Fi, Bluetooth, or network on your Samsung phone, it’s worth ...

View more: How to Reset Network Settings on Samsung

Orion captures haunting pictures of the Lunar surface

NASA’s Artemis I mission lifted off from Earth just a few short weeks ago, and since then, the Orion capsule has captured a breathtaking view of Earth and even completed its lunar flyby. While preparing to enter what NASA calls a distant retrograde orbit, the Orion capsule also managed ...

View more: Orion captures haunting pictures of the Lunar surface

Where to find Qwilfish in Pokémon Scarlet and Violet

Ford’s New Electric Van Tows Your Family Into the Future

Today in Apple History: Bill Gates hails Mac as the future of computing

How to Use Google Drive Files Offline on Mac

FIFA 23: How to complete Showdown Jose Maria Gimenez vs. William Carvalho SBC – Requirements and solutions

How to get Snorunt Fur in Pokémon Scarlet and Violet

How to Hide a Slide in Google Slides

Overwatch 2 Ramattra gameplay trailer shows his furious fists at work

Where to find Clauncher in Pokémon Scarlet and Violet

Instructions on how to change the IP of iOS and Android phones simply and quickly

How to Find and Use Instagram Reels Templates

Elder Scrolls 6 release date may be with UK gov, but it’s not telling


Top Car News Car News