Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
findstr
Command

In computing, findstr is a command in the command-line interpreters (shells) of Microsoft Windows and ReactOS. It is used to search for a specific text string in computer files.

We don't have any images related to findstr yet.
We don't have any YouTube videos related to findstr yet.
We don't have any PDF documents related to findstr yet.
We don't have any Books related to findstr yet.
We don't have any archived web articles related to findstr yet.

Overview

The command sends the specified lines to the standard output device.5 It is similar to the find command. However, while the find command supports UTF-16, findstr does not. On the other hand, findstr supports regular expressions, which find does not. The findstr program was first released as part of the Windows 2000 Resource Kit under the name qgrep.6

findstr cannot search for null bytes commonly found in Unicode computer files.7

Syntax

FINDSTR flags strings [drive:][path]filename[...]

Arguments:

  • flags This can be any combination of flags described below.
  • strings Text to be searched for.
  • [drive:][path]filename Specifies a file or files to search.

Flags:

  • /B Matches pattern if at the beginning of a line.
  • /E Matches pattern if at the end of a line.
  • /L Uses search strings literally.
  • /R Uses search strings as regular expressions.
  • /S Searches for matching files in the current directory and all subdirectories.
  • /I Specifies that the search is not to be case-sensitive.
  • /X Prints lines that match exactly.
  • /V Prints only lines that do not contain a match.
  • /N Prints the line number before each line that matches.
  • /M Prints only the filename if a file contains a match.
  • /O Prints character offset before each matching line.
  • /P Skip files with non-printable characters.
  • /OFF[LINE] Do not skip files with offline attribute set.
  • /A:attr Specifies color attribute with two hex digits. See "color /?"
  • /F:file Reads file list from the specified file(/ stands for console).
  • /C:string Uses specified string as a literal search string.
  • /G:file Gets search strings from the specified file(/ stands for console).
  • /D:dir Search a semicolon delimited list of directories

Note: Following command displays the detailed help about this command:

FINDSTR /?

Example

Save your running services into file _services.txt and search in this file for lines containing word "network" - case insensitive:

@echo off set searchstr=network net start>_services.txt FINDSTR /I "%searchstr%" _services.txt pause

output would be:

Network Connections Network List Service Network Location Awareness Network Store Interface Service Windows Media Player Network Sharing Service Press any key to continue . . .

See also

Wikibooks has a book on the topic of: Guide to Windows Commands

Further reading

  • Stanek, William R. (2008). Windows Command-Line Administrator's Pocket Consultant, 2nd Edition. Microsoft Press. ISBN 978-0735622623.
  • John Paul Mueller (2007). Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000. John Wiley & Sons. ISBN 978-0470165799.

References

  1. Microsoft WinXP documentation for findstr https://technet.microsoft.com/en-us/library/bb490907.aspx

  2. Microsoft Server 2012/2016 documentation for findstr https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr

  3. "Reactos/Reactos". GitHub. 16 October 2021. https://github.com/reactos/reactos/blob/master/base/applications/findstr/findstr.c

  4. MS-DOS and Windows command line findstr command https://www.computerhope.com/findstr.htm

  5. Excellent documentation on usage of findstr https://stackoverflow.com/questions/8844868/what-are-the-undocumented-features-and-limitations-of-the-windows-findstr-comman#8844873

  6. History of Findstr from Raymond Chen https://devblogs.microsoft.com/oldnewthing/20121128-00/?p=5963

  7. Findstr - Search for strings - Windows CMD - SS64.com https://ss64.com/nt/findstr.html