Search inside files from the command line with findstr

Use the built-in findstr tool to find text inside files, including all subfolders, with case-insensitive matching and line numbers.

WindowssearchcmdtextLow risk
Run: findstr /s /i /n "TODO" *.txt to list every matching line in all .txt files under the current folder.

01Command

Command
$ findstr /s /i /n "TODO" *.txt

02What it does

findstr is the Windows built-in text-search tool. /s makes it search the current folder and all subfolders, /i ignores letter case, and /n prints the line number of each hit. Wrap multi-word phrases in /c:"two words" so they're treated as one literal string instead of separate words.

03Risk

RiskLow risk
!Warning: findstr only matches plain text well; it will return garbled hits on binary files, so restrict it with a file pattern like *.txt.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Findstr - Search for patterns in files
    SS64.com · technical · 2026-09-17
    Evidence: Documents /s (search subdirectories), /i (case-insensitive), /n (print line numbers) and /c for literal strings in findstr.
  • findstr (Windows Commands)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Official findstr reference listing /s, /i, /n, /v and /c switches for searching files and subdirectories, case-insensitively and with line numbers.

Last verified: 2026-09-19 · Category: Files & Folders

06Related solutions