How To Use FINDSTR Command In Windows 11

You may have placed some files in your Windows 11, but you have forgotten their names now. Don’t worry, the findstr command will help you‌. It’s a built-in tool in every Windows but mostly under-used and underrated because of less knowledge for findstr command .

This article will help you learn step-by-step the use of the findstr command. To search a file in manual research can be frustrating and time-consuming. The findstr command line can search files by content in windows 11. This command will be excellent for you if you know how to use it correctly. To use the findstr command in Windows 11.  You need to go a couple of steps;

Open The Command Prompt

The first step to use the findstr command is to pop up the command prompt.

Step 1 You need to click on the file explorer.

Step 2 As soon as the explorer window throws up, enter “cmd” on the search bar. The window of command prompt will be open before you.

Figure 1 search cmd in the search bar

Figure 1 search cmd in the search bar

Step 3 you need to use right-click on the respective window through your mouse and choose the run option as administrator. Windows command is ready for the findstr command line.

Open command prompt

Open command prompt

Findstr Command Help

Type “findstr /?” in a Command Prompt window, to see the help information and Findstr syntax. keep reading to learn some Findstr command examples.

C:\Users\Administrator>findstr /?
Searches for strings in files.

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
strings [[drive:][path]filename[ ...]]

/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
strings Text to be searched for.
[drive:][path]filename
Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C. For example, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

Find The Location Of The Content

Step 1 For content search, you need to type findstr syntax on the command prompt.

Step 2 The next step is to add /s if you want to search in sub-folders.

Step 3 Further step, you will enter the text of the respective file.

Step 4 Now, you will add “.” if you want to search in many files, whether pdf or text file type or any file, throughout the computer data. If you want to search only in the text file, you will write. Text and press enter.

findstr /s mushroom"."

Or

findstr /s mushroom .text

The window prompt will show you the location of the respective file.

Search file by content under the document

For searching a specific file, you need to use syntax to type the command line for search. For example, you need to find document “occurrence. text” under the documents of the folder along with the word “window 11,” then entering the findstr command will be like:

findstr /c:/documents/ “window 11” occurrence.text

Now for any file search in the d folder for the word computer, you will type findstr syntax on the command prompt.

findstr "computer" d:\ documents\. ""

Search For Words Ending With Specific Texts

Suppose you want to search all the words ending with “ABC” in every type of file under D:/ Documents/ including all the sub-folders, the findstr command will look like;

findstr / R /S [a-z]* ABC d:\ documents\* .txt

Here, /S is a syntax for searching all the folders and sub-folders under document D.

/R says for search content strings while * presents a string search in all the folders present on the computer.

Process string for all the words end wither. Here, findstr string in the folder text3 will look.

 findstr /r [ a-z]* er test3. txt

Text Search In The File By Findstr Command

findstr made finding content in the file or maybe even files easier. A better understanding of the findstr command-line tool will provide you with the required word document in seconds.

Suppose you look for documents with specific words in your windows 11 and forget about the file name. For example, your word is a dictionary in a specific file y.z. Here, your findstr syntax will be:

findstr dictionary y.z

To Find Files In A Specific Location

To find text in a specific document word to be searched will come in inverted commas for folders and sub-folder search. /c findstr will help find the specific word “dictionary.”

By considering the above example, the findstr command line will be like:

findstr /c:" dictionary" y.z

For Text Occurrence Search

Occurrence of the word means that you want in a specific case like Dictionary where D is capital in the file tor. text, enter the findstr standard line like

findstr Dictionary Tor. text

Search Text Irrespective Of Case

Search for text without the specification of case types, whether capital or small, the findstr command that you will enter

findstr /s /i Dictionary “.”

In this syntax typing, /s uses folders and sub-folder search while I/ give the command to ignore the case “D,” whether capital or small.

Search Text With Different Specifications

Suppose you are looking for a text at the start of the line. You want this word along with multiple spaces and with the line number. Here, the syntax of the findstr command in window 11 will be.

findstr /b /n /r /c : ^ *too  *. bas

Here, /b symbolizes displaying a word too if it’s at the start of a line and /n for the number line display in which the word is present. /r means text search processing. Last, /c made the search text exact.

Findstr Multiple Strings

To search for multiple sentences in a file and redirect the output, you can refer to the command below:

findstr /C:"the first search" /C:" a second search " /C:"and another" sourcefile.txt > results.txt

Search for lines that do not contain either “black” or “white”:

findstr /v "black white" blackwhite.txt

If you want to search for over one text in multiple folders with specific search criteria in stringlist.txt and files research in the file list, you want to see the results in the file results.out. The following findstr syntax will help you.

findstr / g: stringlist. txt  / f: filelist. txt > results.out

Here /g uses to search specific content from the listed file, /f uses for a specific file search from listed files while > shows the content display position and results. Out is the point where content needs to be displayed.

Looking for a file that contains the word thewidedictionary, findstr syntax in window 11 will be like.

findstr /s /i /m \ <thewidedictionary\>  *.*

Here, /s uses current folders and subfolders for string search and /I to overlook the case type. /n is used to search specific file names in which the text is present.

If you want to search for the words that begin with the and others containing the vast dictionary, then findstr syntax will be

findstr /s /i /m \<the . *  *. *

Here * uses for occurrence, /s for exact string processes. /I ignore the case type /m used for specific filename displays.

Findstr Regex

To use regular expressions to search for patterns of text, use the /R parameter. This is the default setting if no other parameter is specified. For example, findstr /R “^SFC” *.txt will find all lines that start with SFC using the ^ meta-character in any text file in the current directory and its subdirectories.

String Search For An Exact Match

findstr /s "computer help" *. Txt

Here, /s uses for the search in current folders and sub-folders while * shows the accuracy of words from zero or more in the string line. Another example for findstr exact match will be

findstr /x  /c: “computer work” *.txt

For the exact string display on the window prompt, you can use / x. In this case, you will not see “computer works” or other unmatched files on the window prompt. / x must be a line, which means that there should be nothing other than “computer work” in the line to match the exact results. Similarly, * uses for the accuracy of computer work word in the files.

For example, you need to find the word “computer work” in the file named myfile So, the findstr command that you will enter in the window prompt will be like

findstr “computer work” myfile.txt

It’s that easy to find string through your files.

String Search In Folder

Proceeding the above example, you can make changes in the findstr syntax to add the specification of folders. It means that findstr will show results by finding the content and the file name that possesses the content. The findstr command line on window 11 will be like

 findstr /s “computer work” * .txt

Here, /s shows the results from current data and sub-folders of the computer, while * shows the exact place of computer work in files. You can also observe that the above findstr command does not mention the filename. It means findstr will search the required word through all directories on the computer. Txt symbol shows the files with text. It means that the findstr command will search strings from all the text files on window 11.

For the word aaa, the findstre command in Windows 11 will be

findstr command search for a string in window 11

findstr command search for a string in window 11

String Search For Number Lines

The findstr syntax on the command prompt will look like

findstr /n /i /c: “computer work” *

Here, /n presents the line numbers before each line matches the required string. /I show that the search is not case-sensitive. When you press after entering this findstr command on the window prompt, search results will show you the lines before the word computer work.

Conclusion

You can use the findstr command in any command-line interpreter if you understand every meta character, parameter, and functionality through the ways mentioned earlier. It will help you ‌grip on findstr command usage.

Through the findstr tool, you can easily do a successful file search in Windows 11. The most significant advantage of the findstr command is it’s a built-in tool. Hopefully, you have learned what Findstr command you should use to search text content. 

However, if you think this is too complicated to search files, you may try AnyTXT, a GUI tool for searching files by content.