# Findstr

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Findstr
> Markdown URL: https://mediated.wiki/source/Findstr.md
> Source: https://en.wikipedia.org/wiki/Findstr
> Source revision: 1351849852
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description| Shell command for searching text files}}
{{lowercase}}
{{Infobox software
| name                   = findstr
| logo                   = 
| screenshot             = 
| screenshot size        = 
| caption                = 
| other_names            = qgrep
| developer              = [Microsoft](/source/Microsoft), ReactOS Contributors
| released               = 
| latest release version = 
| latest release date    = 
| operating system       = [Windows](/source/Microsoft_Windows), [ReactOS](/source/ReactOS)
| platform               = [Cross-platform](/source/Cross-platform)
| genre                  = [Command](/source/Command_(computing))
| license                = Windows: [Proprietary](/source/Proprietary_software) [commercial software](/source/commercial_software)<br />
ReactOS: [GNU General Public License](/source/GNU_General_Public_License)
| website                = {{URL|https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr}}
}}
'''{{code |findstr}}''' is a [shell](/source/Shell_(computing)) [command](/source/command_(computing)) that searches for text in [files](/source/computer_file)<ref>[https://www.computerhope.com/findstr.htm MS-DOS and Windows command line findstr command]</ref> and prints matching lines to [standard output](/source/standard_output).<ref>[https://stackoverflow.com/questions/8844868/what-are-the-undocumented-features-and-limitations-of-the-windows-findstr-comman#8844873 Excellent documentation on usage of findstr]</ref>
The command provides similar functionality as <code>[find](/source/find_(Windows))</code>, but <code>findstr</code> supports ''some'' [regular expression](/source/regular_expression) operators. However, <code>findstr</code> does not support [UTF-16](/source/UTF-16) whereas <code>find</code> does. <code>findstr</code> cannot search for [null bytes](/source/Null_character) commonly found in [Unicode](/source/Unicode) computer files.<ref>[https://ss64.com/nt/findstr.html Findstr - Search for strings - Windows CMD - SS64.com]</ref>

<code>findstr</code> was first released as part of the [Windows 2000](/source/Windows_2000) [Resource Kit](/source/Resource_Kit) under the name <code>qgrep</code>.<ref>[https://devblogs.microsoft.com/oldnewthing/20121128-00/?p=5963 History of Findstr from Raymond Chen]</ref>
The command is available in [Windows](/source/Windows)<ref>[https://technet.microsoft.com/en-us/library/bb490907.aspx Microsoft WinXP documentation for findstr]</ref><ref>[https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr  Microsoft Server 2012/2016 documentation for findstr]</ref> and [ReactOS](/source/ReactOS).<ref>{{Cite web|url=https://github.com/reactos/reactos/blob/master/base/applications/findstr/findstr.c|title = Reactos/Reactos|website = [GitHub](/source/GitHub)|date = 16 October 2021}}</ref> 

==Use==
The command syntax can be described as:

 findstr FLAGS TEXT PATH...

; TEXT: Text to search for.

; PATH: [Path](/source/Path_(computing)) to a file.

FLAGS: 
; <code>/B</code>: Match pattern if at the beginning of a line.

; <code>/E</code>: Match pattern if at the end of a line.

; <code>/L</code>: Use search strings literally.

; <code>/R</code>: Use search strings as regular expressions.

; <code>/S</code>: Search for matching files in the current directory and all subdirectories.

; <code>/I</code>: [Ignore case](/source/Case_sensitivity) for matching.

; <code>/X</code>: Print lines that match exactly.

; <code>/V</code>: Print lines that do ''not'' match.

; <code>/N</code>: Print the line number before each line that matches.

; <code>/M</code>: Print only the [file name](/source/file_name) if a file contains a match.

; <code>/O</code>: Print character offset before each matching line.

; <code>/P</code>: Skip files with [non-printable character](/source/non-printable_character)s.

; <code>/OFF[LINE]</code>: Do not skip files with offline attribute set.

; <code>/A:attr</code>: Specifies color attribute with two hex digits. See "color /?"

; <code>/F:file</code>: Reads file list from the specified file (/ for console).

; <code>/C:string</code>: Use specified string as a literal search string.

; <code>/G:file</code>: Get search strings from the specified file (/ for console).

; <code>/D:dir</code>: Search a semicolon delimited list of directories

; {{code|/?}}: Print help information about the command.

==Example==
The following command searches the file named "services.txt" for lines containing "network" ignoring case.

<syntaxhighlight lang="dosbatch">
findstr /i "network" services.txt
</syntaxhighlight>

==See also==
{{Wikibooks |Guide to Windows Commands}}
* {{Annotated link |List of DOS commands}}
* {{Annotated link |Find (Unix)}}
* {{Annotated link |grep}}

==References==
{{Reflist}}

==Further reading==
*{{Cite book|first=William R.|last=Stanek|year=2008|title=Windows Command-Line Administrator's Pocket Consultant, 2nd Edition|publisher=[Microsoft Press](/source/Microsoft_Press)|isbn=978-0735622623}}
*{{Cite book|author=John Paul Mueller|year=2007|title=Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000|publisher=[John Wiley & Sons](/source/Wiley_(publisher))|isbn=978-0470165799}}

==External links==
*[https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr findstr | Microsoft Docs]

{{Windows commands}}

Category:Microcomputer software
Category:Windows administration
Category:Pattern matching

---
Adapted from the Wikipedia article [Findstr](https://en.wikipedia.org/wiki/Findstr) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Findstr?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
