> Commands A-M
> Commands F
Search for strings in files.
- The file(s) to search.
- Text to search for. If multiple words
(separated by spaces) in string, can match ANY ONE of the
- Display help.
- Specifies color attribute with two hex digits. See
- Match pattern if at the Beginning of a line.
- Use string as a literal search string. If multiple words
(separated by spaces) in string, must match ALL of the words.
- Search a semicolon-delimited list of directories.
- Match pattern if at the END of a line.
- Get a list of pathname(s) from a file
(/ stands for console). Multiple files (each file on a
new line) to search can be specified with a source file.
- Get search string from a file (/ stands for console).
Multiple search criteria (each item on a new line) can be
specified with a file.
- Case-insensitive search.
- Use search string(s) literally.
- Print only the filename if a file contains a match.
- Print the line number before each line that matches.
- Print character offset before each matching line.
- Processes files with offline attribute set.
- Skip any file that contains non-printable characters.
- Use search string(s) as regular expressions.
- . Wildcard: any character
- * Repeat: zero or more occurances of previous character or class
- ^ Line position: beginning of line
- $ Line position: end of line
- [class] Character class: any one character in set
- [^class] Inverse class: any one character not in set
- [x-y] Range: any characters within the specified range
- \x Escape: literal use of metacharacter x
- \<xyz Word position: beginning of
- xyz\> Word position: end of word
- Search current folder and subfolders.
- Print only lines that do NOT contain a match.
- Print lines that match exactly.
FIND - Search for a text string
in a file.
MUNGE - Find and Replace text within
Equivalent Linux BASH commands:
grep - Search file(s) for lines that match a given pattern.
gawk - Find and Replace text within file(s).
tr - Translate, squeeze, and/or delete characters.
search for "granny" OR "Smith" in MyFile.txt:
FINDSTR "granny Smith" MyFile.txt
Search for "granny Smith" in MyFile.txt
(effectively the same as the FIND command):
FINDSTR /C:"granny Smith" MyFile.txt
Search every file in the current folder and all subfolders
for the word "Smith", regardless of upper/lower case:
FINDSTR /S /I smith" *.*
To find every line containing the word SMITH, preceeded by any
number of spaces, and to prefix each line found with a consecutive
FINDSTR /B /N /C:" *smith" *.*
Finding a string only if surrounded by the standard delimiters To
find the word "computer", but not the words "supercomputer" or
FINDSTR "\<computer\>" MyFile.txt
Now assume you want to find not only the word "computer", but also
any other words that begin with the letters comp, such as "computerise"
FINDSTR "\<comp.*" MyFile.txt
Use the search criteria in CRIT.TXT and search the files listed in
FILES.TXT then store the results in the file RESULTS.OUT:
FINDSTR /G:CRIT.TXT /F:FILES.TXT > RESULTS.OUT
- Windows NT