findstr review: Handy Windows tool for command searches for text strings

Martin Brinkmann
May 4, 2018
Updated • Oct 1, 2021
Software, Tutorials

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. In other words, if you want to find specific exact match text strings in files, in a command-line output, or elsewhere, you may use the free findstr command on Windows to do so. It is available in all major Windows versions including Windows 10.

You can use the application to filter command-line outputs and 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, and Everything support finding text in files as well.

What is findstr – Search for Text in Windows Files

Example of findstr on Windows CMD

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 specific text in command line outputs quickly.

You can run findstr from the command line or as a batch file. Open a new command line prompt by clicking on the Windows-key, typing cmd.exe, and selecting the result. Alternatively, use the Run command to open findstr.

Some Useful Parameters in findstr

As you explore findstr, the following parameters will help you find specific texts. For example, you can look for exact match or case-sensitive words inside files.

  • /? -- 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 number

findstr Examples That You May Find Useful

Consider these examples to try with findstr:

  • ipconfig | findstr "192.168" -- The command runs ipconfig and returns any result that matches 192.168. Any other result is ignored.
  • netstat | findstr "" -- 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.

Advanced options include returning content that is found at the beginning or end of lines, using regular expressions, or using wildcards.

Closing words

findstr'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. It’s free, quick, and easy to use – what more do you need from a search tool?

Now you: Which program do you use to find text in files?

findstr: Find text in any file, command on Windows
Article Name
findstr: Find text in any file, command on Windows
findstr command: Use Windows findstr to search for text strings in any file or command-line output using CMD or PowerShell or batch scripts. See examples.
Ghacks Technology News

Previous Post: «
Next Post: «


  1. Janet Nesmith said on April 26, 2020 at 8:20 pm

    I want to look for word XX in all files with names containing YY. How to do that?

  2. Alexd said on October 24, 2019 at 2:58 pm

    This is useless if the purpose is to locate a certain string where you don’t know where it is in a file in subdirectory.. if I knew the file, I just load into my favorite text editor.

    So your title is misleading “to find text in files and command outputs” –

  3. RealDarkMan said on June 1, 2019 at 9:25 am

    Hi Everyone
    This can be useful for some of you.
    dir /s /b | findstr “word” – searches for string word in each line anywhere within the line
    dir /s /b | findstr “^word” – searches for string word in each line and returns result only if the line starts with this string
    dir /s /b | findstr “word$” – searches for string word in each line and return result only if line finishes with this string
    Good luck

  4. sal said on May 8, 2019 at 1:20 pm

    I use the findstr /n “aaaa” “mypath”
    to extract number of line where mystring is found.

    But if i have:

    in c:\mypath\t.txt the code return 1 aaa, 2 aaa, 3 aaa
    for my use i need only the number of first occurrence, in my case 1 aaa

    How to?

  5. Chris said on October 22, 2018 at 1:22 pm

    Hi i need to find this line in a file:” ”

    There is 2Tab and some ” in the line…

    Is it possible to somehow sertch for the line with ” in it, without make it a new string

    This is the output i get…

    X:\as\tomcat-XXXXX\webapps\XXXXX\WEB-INF\classes>findstr /C:”” XXXXX-job.xml
    FINDSTR: Cannot open 0
    FINDSTR: Cannot open 3
    FINDSTR: Cannot open ? />

  6. Marcos said on September 13, 2018 at 4:23 am

    findstr /s /i /n /p /c:”123.exe” lista1>>result
    lista1:117:123.exe 2392 Console 1 33.328 k

    Preciso encerrar a task 123.exe varias vezes, e quero facilitar com um arquivo.BAT.
    Gostaria de completar este BAT onde obtivesse o valor do PID (2392) desta task,
    á ser encerrada, já que ele muda toda vez que 123.exe reinicia. (Após as 2 linhas acima)
    obtive o arquivo result (3a linha).
    Como se faz para usar este novo PID no final do BAT ? ex:
    “taskkill /PID 2392”

  7. carlos said on May 19, 2018 at 9:26 am

    When you search for texts in multiple (log) files, then maybe this helps:

    $path = “C:\Temp\logFiles”
    $searchString = “Critical Error”

    Get-ChildItem -Path $path -Filter “*.log” | Select-String -Pattern $searchString | select Filename, Line

    The filter is not really needed in this particular example, but might be useful in other cases.

  8. Anonymous said on May 8, 2018 at 10:01 pm

    Nirsoft’s SearchMyFiles is able to search the content of text-based files (eg. TXT, XML, INI, CFG, etc.)

  9. TelV said on May 8, 2018 at 11:45 am

    findstr can also be used in combination with DISM. For example:

    dism /online /get-packages | findstr 2976978

    If KB2976978 which is Microsoft’s perrenial telemetry package for 8.1 was installed it would result in:
    Package Identity : Package_for_KB2976978~31bf3856ad364e35~amd64~~

    To remove via a command prompt: wusa /uninstall /kb:2976978 /quiet /norestart

    1. TelV said on May 8, 2018 at 12:00 pm

      Actually, come to think of it, the remove command should be:

      DISM.exe /Online /Remove-Package /PackageName:Package_for_KB2976978~31bf3856ad364e35~amd64~~ /quiet /norestart

      The actual version number, in this particular example, may vary since M$ is still trying to persuade 8.1 users to install this crap and it reappeared last month I noticed.

  10. STech said on May 7, 2018 at 8:37 pm

    For my use cases I use often findstr on results piped from ‘strings’ by sysinternals. It’s not the most powerful tool, but it’s just fine for quick jobs.
    Thank you Martin. Good tutorial that helps people to find some simple but very useful tools.
    PS: Thanks Jessica. I always forget about that Powershell has the same tools as cmd (and much more), and often more powerful.

  11. Robert G. said on May 5, 2018 at 3:29 am

    I use grepWin x64 Portable when I search something inside my batch files:

  12. Maarten said on May 5, 2018 at 2:36 am

    I use FINDSTR all the time (and sometimes PowerShell).
    Note that FINDSTR does’t support output of all command line tools. For example the output of REG.exe (UCS2-LE encoded) and possibly all unicode files can not be read.
    Workaround is: TYPE file | findstr parms or using oldschool FIND command.

    BTW: Someone did some *really* serious FINDSTR research and found undocumented features and bugs. That can be found here:
    Warning: long read.

    I really like Everything, but mostly for finding files, not content.
    Filenames are indexed; content is not (luckily!), so that might take a little longer compared to the ‘normal’ lightspeed of Everything.

    1. Martin Brinkmann said on May 5, 2018 at 7:29 am

      Great information, thanks a lot Maarten!

  13. Jessica said on May 4, 2018 at 10:27 pm
    1. Martin Brinkmann said on May 5, 2018 at 7:13 am

      Thank you Jessica!

  14. Anonymous said on May 4, 2018 at 4:47 pm

    Agent Ransack is the best.

    1. BM said on May 5, 2018 at 7:25 am

      You mean FileLocator Lite?

      Been using that for years.

      Still findstr might have its uses.

      I like the Cortana suggestion above by lazyfingers. Always kind of ignored it but for looking up some administrative functions. I do see the documents section and it works like a charm, though I do like FileLocator Lite better.

  15. Mark Hazard said on May 4, 2018 at 4:02 pm

    Thanks for the article, Martin. I didn’t know the command existed.

  16. lazyfingers said on May 4, 2018 at 3:10 pm

    Hate to say it but I use Win10 search engine in Cortana. It has icon filters for documents, photos, music, etc. ex. you want to find ‘apples’ in a doc you have but can’t recall which one (and the file name doesn’t have ‘apples’ in it). Just type apples in the search box, click documents icon, and there it is. Everything app may find text too but it seemed more complicated.

    1. John Fenderson said on May 5, 2018 at 12:15 am

      What’s your secret? I can never get Windows 10 search to find anything.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.