If you’re switching from Linux to Windows and missing the comfort of grep or find, don’t worry — Windows has tools for that too. While PowerShell is your go-to command-line solution, there are also classic cmd commands and third-party utilities to get the job done.
This post walks you through how to search for specific text in files and folders on Windows, with examples for PowerShell, Command Prompt, and other tools. Whether you’re a developer or just managing a lot of files, these tips will save you time.
1. PowerShell: The Modern Way
PowerShell is the most powerful built-in tool on Windows for searching text in files. Here’s how to use it.
Basic Search:
Get-ChildItem -Recurse -File | Select-String 'class="itemExtraFields"' | Select-Object Path, LineNumber, Line
This command will:
Search all files in the current folder and subfolders.
Look for the string class=”itemExtraFields”.
Show you the file path, line number, and the actual line of text.
Filter by File Type (e.g., if you want to search only .html or .php files):
Get-ChildItem -Recurse -Include *.html,*.php -File | Select-String 'class="itemExtraFields"'
Save Results to a File:
... | Out-File results.txt