Saturday , April 19 2025

How to search for text in files on Windows

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.

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

Command Prompt (cmd.exe)

If you’re more old-school or just don’t like PowerShell:

findstr /S /I /M "itemExtraFields" *.*

Explanation:

  • /S – search subfolders
  • /I – ignore case
  • /M – show only the filenames with matches

To show matching lines as well:

findstr /S /I "itemExtraFields" *.*

Limiting to .html files:

findstr /S /I "itemExtraFields" *.html

Just a note, findstr doesn’t handle special characters as well as PowerShell (especially quotes or regex), but it’s fast and lightweight.

Notepad++: GUI Way to Search in Files

For those who prefer a GUI:

  1. Open Notepad++
  2. Press Ctrl+Shift+F to open Find in Files
  3. Enter your search term: class=”itemExtraFields”
  4. Choose the directory and file types to search
  5. Click Find All

This is great for quickly previewing matches and jumping between files.

Git Bash or WSL: Bring Linux Tools to Windows

If you’ve installed Git for Windows, you get grep!

grep -r 'class="itemExtraFields"' .

And if you use WSL (Windows Subsystem for Linux):

find . -type f -exec grep -H 'class="itemExtraFields"' {} \;

Perfect for those who miss their native Unix tools.

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Leave a Reply

Your email address will not be published. Required fields are marked *