
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
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!