grep is the most used and powerful command line tool available for Unix and Linux Distributions, if you are a Windows Operating System and wondering if there is a similar or alternative to grep for Command Line - CMD or PowerShell, well findstr is the command you should look at.
Example: grep vs findstr:Linux/Unix/macOS
# ls| grep sample.txt
Windows: CMD/PowerShell
C:\> dir | findstr sample.txt
Some Findstr Examples
To find the word Michael in songs.txt file.
> findstr Micheal songs.txt
To find the word Easter or Christmas in songs.txt file.
> findstr Easter Christmas songs.txt
To find the String Micheal Jackson in songs.txt file.
> findstr "Micheal Jackson" songs.txt
Case insensitive search /i
> findstr /i "Micheal Jackson" songs.txt
Meta-character:
. Wildcard - Any character
* Repeat - Zero or more occurrences of the previous character.
^ Beginning line position - Beginning of the line.
$ End of the line.
[x-y] Range - Any characters within the specified range.
\x Escape - Literal use of a meta-character.
\ Ending word position
Read More: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Fix Windows Update Error Code: 0x80070643
- How to Create Awesome Quizzes using Windows 365 Forms
- [Fix] Microsoft Windows Store error 0x00000005 (Windows 8/10/11)
- Windows 365: Restore Deleted Distribution Group using Admin Center (Active Directory)
- How to Change Encoding of File from ANSI to UTF-8 in Windows Notepad
- How to Change the Default Shell in Windows Terminal App
- How to Create a Website (Webpage) using HTML on Windows Notepad
- How to Find the Location of Notepad on Windows 11
- How to locate Python Installation on Windows (10/11)
- Top 5 Fonts for Windows Notepad
- Fix: Windows Update Error Code: 0x800f0922
- Office.com downloading zero byte file name prelanding on Safari browser
- How to Search in Notepad Application on Windows
- Cannot access Windows application shortcuts on Start menu and Taskbar
- How to add Solver Add-in in Microsoft Excel on Mac
- How to Freeze Top Row in Excel for Mac
- [Fix] Microsoft Windows OneDrive 0x8007018b Error Code
- Mac: Sign in Required We cant upload or download your changes because your cached credentials have expired [Word Excel]
- Grep Alternative for Windows CMD or PowerShell: findstr
- Fix: Failed in attempting to update the source: winget
- How to lock cells in Microsoft Excel for Mac
- Enable Cloud Based Clipboard for Images and Text on Windows 10/11
- How to update Microsoft Excel on Mac
- How to Make a Windows Notepad File Read-Only
- sudo is not recognized as an internal or external command
- connection.url property value in hibernate.cfg.xml for mysql - Java
- How to filter null values using Java 8 Stream API - Java
- What is the Default Admin user and Password for Jenkins - Linux
- How to see Storage Information on macOS Ventura - MacOS
- How to install Python 3.9 using brew on Mac - Python
- Simple Login Page using Bootstrap - Bootstrap
- How to change order of fields on new item form for SharePoint Online list - SharePoint
- [Fix] SharePoint: This embed code doesnt seem to work. We only support iframe based embeds - SharePoint