Skip to main content

Command referencefindstr

findstr command (Windows / CMD)

WindowsCMDtextbeginner

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 / optionMeaning
/IIgnore letter case.
/SSearch matching files in the current tree.
/NPrint line numbers.
/LTreat search strings literally.
/RUse 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.

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.