|
FINDSTR
Search for a string in a file or files. More powerful than
FIND.
Syntax
FINDSTR [options] [/F:file] [/C:string] [/G:file] [string(s)] [pathname(s)]
Key
string Text to search for.
pathname(s) Specifies a file or files to search.
/C:string Use string as a literal search string.
/G:file Gets search strings from the specified file.
/F:file Reads file list from the specified file.
/d dirlist Search a comma-delimited list of directories.
options may be any combination of the following switches:
/I Case-insensitive search.
/S Searches for matching files in the current directory
and all subdirectories.
/P Skip any file that contains non-printable characters
/L Uses search strings literally.
/R Uses search string(s) as regular expressions.
/B Matches the pattern if at the beginning of a line.
/E Matches the pattern if at the end of a line.
/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 file name if a file contains a
match.
/O Prints character offset before each matching line.
/a color_attribute Specifies color attributes with two
hexadecimal digits.
Findstr is capable of finding the exact text you are looking
for in any ASCII file or files.
When the search string contains multiple words (separated
with spaces) then FINDSTR will show show lines that contains
any one word - this behaviour is reversed if the string
argument is prefixed with /C.
Multiple search criteria can be specified with a script
file /G.
Multiple files to search can be specified with a source
file /F.
Examples
To search for "hello world" in file x.y, type:
FINDSTR /c:"hello world" x.y
Search for "John" OR "Smith" in File.txt.
FINDSTR "John Smith" File.txt
To search every file in the current directory and all
subdirectories that contained the word Batch, regardless
of the letter case, type the following:
FINDSTR /s /i Batch *.*
Use spaces to separate multiple search strings unless the
argument is prefixed with /c. To search for "hello" or
"world" in file x.y, type:
FINDSTR "hello world" x.y
To find all occurrences of the word "Batch" in the file
File.txt, type the following:
FINDSTR Batch file.txt
Cmd Commands
|