17 December 2024
·Findstr: The Windows Grep Equivalent Tool
Need to search text in files using Windows Command Prompt? Findstr is your built-in solution - no installation needed.
Basic Usage
findstr "search-term" "path\to\file.txt"
Essential Switches
/i
- Ignore case/c:"text"
- Search for literal text string/s
- Search in current directory and all subdirectories/n
- Display line numbers with output lines/v
- Display lines that do not contain the search string
Practical Examples
Case-insensitive search:
findstr /i "error" log.txt
Search for exact phrase:
findstr /c:"hello world" message.txt
Recursive search in all text files:
findstr /s /i "warning" *.txt
Multiple file search:
findstr "error" log1.txt log2.txt log3.txt
Pro Tips
- Combine switches for powerful searches:
findstr /s /i /n "error" *.log
- Use wildcards for file types:
findstr /s "password" *.*
- Search for multiple strings:
findstr "error warning critical" log.txt
Finding text in Windows doesn't have to be complicated. Findstr provides grep-like functionality right out of the box.