Command referencefindstr
findstr command (Windows / CMD)
What it does
Search files or piped text using literal strings or regular expressions. Searches for the findstr command cmd usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Search files or piped text using literal strings or regular expressions.
Syntax
findstr [/B] [/E] [/L | /R] [/S] [/I] [/N] strings [[drive:][path]filename ...]
Common options
| Flag / option | Meaning |
|---|---|
| /I | Ignore letter case. |
| /S | Search matching files in the current tree. |
| /N | Print line numbers. |
| /L | Treat search strings literally. |
| /R | Use regular expressions. |
Practical examples
Search file
findstr /N /I "error" app.log
Finds error lines regardless of case.
Recursive search
findstr /S /I "TODO" *.txt
Searches text files below the current folder.
Filter command
tasklist | findstr /I "node"
Shows process rows containing node.
Linux ↔ Windows equivalent
Closest match: grep (Linux / bash / sh / zsh). Search text for lines matching a pattern.
Common mistakes
- Assuming findstr supports the same regular-expression syntax as grep.
- Forgetting `/C:"multi word"` when a phrase must be one search string.
Related commands
- typeDisplay the contents of one or more text files.
- Select-StringSearch strings and files with .NET regular expressions.
- grepSearch text for lines matching a pattern.
- Where-ObjectFilter pipeline objects by property values or a script block predicate.
- catConcatenate files and write their contents to standard output.
- Get-ContentRead file content or provider data as a stream of objects.
- echoWrite arguments and shell-expanded values to standard output.
- echoDisplay text or control command echoing in a batch script.
FAQ
What does findstr do in Command Prompt?
Search files or piped text using literal strings or regular expressions.
How do I run findstr in CMD?
Open Command Prompt and follow `findstr [/B] [/E] [/L | /R] [/S] [/I] [/N] strings [[drive:][path]filename ...]`; quote paths containing spaces.
What is a practical findstr example in CMD?
Try `findstr /N /I "error" app.log` — Finds error lines regardless of case.
Can findstr be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.