Overview
The command sends the specified lines to the find
command. However, while the find
command supports findstr
does not. On the other hand, findstr
supports find
does not.
The findstr
program was first released as part of the qgrep
.
findstr
cannot search for null bytes commonly found in Syntax
FINDSTR flags strings rive:path]filename .. Arguments: *flags
This can be any combination of flags described below.
*strings
Text to be searched for.
* rive: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 INE/code> 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
*Regular expression
A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
*Wildcard character
In software, a wildcard character is a kind of placeholder represented by a single character (computing), character, such as an asterisk (), which can be interpreted as a number of literal characters or an empty string. It is often used in file ...
* List of DOS commands
* find
*grep
grep is a command-line utility for searching plaintext datasets for lines that match a regular expression. Its name comes from the ed command g/re/p (global regular expression search and print), which has the same effect. grep was originally de ...
References
Further reading
*
*
External links
findstr , Microsoft Docs
{{Windows commands
Microcomputer software
Windows administration
Pattern matching