CMD Master
Back to Blog
Arnošt Havelka

Findstr Command

Advanced text search with regular expressions.

Start Interactive Lesson
Findstr Command

Findstr Command

findstr is the big brother of find. It supports regular expressions (regex), searches recursively across directories, and offers more powerful filtering options. It is comparable to grep in Linux.

Usage:findstr
[/options]
"pattern"
[filename]
/s
Searches for matching files in the current directory and all subdirectories.
/i
Specifies that the search is not to be case-sensitive.
/r
Uses search strings as regular expressions.
/n
Prints the line number before each line that matches.

Common Options

Real-World Examples

1. Finding files containing "TODO" in an entire project

Search every .js file in the current folder and subfolders.

Command Prompt
C:\Users\User>findstr /s /n "TODO" *.js

2. Using Regex to find numbers

Find lines that start with a number.

Command Prompt
C:\Users\User>findstr /r "^[0-9]" data.txt

3. Searching for multiple strings

Find lines containing either "Error" or "Warning".

Command Prompt
C:\Users\User>findstr "Error Warning" app.log

Knowledge Check

1 / 3

Which flag enables recursive search in subdirectories?

Up Next

Advanced Batch

Master loops, conditions, and flow control.