{{Short description| Shell command for searching text files}} {{lowercase}} {{Infobox software | name = findstr | logo = | screenshot = | screenshot size = | caption = | other_names = qgrep | developer = Microsoft, ReactOS Contributors | released = | latest release version = | latest release date = | operating system = Windows, ReactOS | platform = Cross-platform | genre = Command | license = Windows: Proprietary commercial software<br /> ReactOS: GNU General Public License | website = {{URL|https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr}} }} '''{{code |findstr}}''' is a shell command that searches for text in files<ref>[https://www.computerhope.com/findstr.htm MS-DOS and Windows command line findstr command]</ref> and prints matching lines to 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</code>, but <code>findstr</code> supports ''some'' regular expression operators. However, <code>findstr</code> does not support UTF-16 whereas <code>find</code> does. <code>findstr</code> cannot search for null bytes commonly found in 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 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<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.<ref>{{Cite web|url=https://github.com/reactos/reactos/blob/master/base/applications/findstr/findstr.c|title = Reactos/Reactos|website = 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 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 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 if a file contains a match.

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

; <code>/P</code>: Skip files with non-printable characters.

; <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|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|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