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:
# ls| grep sample.txt
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
. 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
Have Questions? Post them here!
- Cmd command get current directory location
- Grep Alternative for Windows CMD or PowerShell: findstr
- [Fix] Microsoft Windows Store error 0x00000005 (Windows 8/10/11)
- Read file from Windows CMD (Command Line)
- [Fix] Microsoft Windows OneDrive 0x8007018b Error Code
- sudo is not recognized as an internal or external command
- [Solution] The connection to the remote PC was lost, preparing to reconnect - Windows RDP
- [fix] java: incompatible types: double cannot be converted to java.lang.Integer Generics - Java
- scp: ssh: connect to host xxxx port 22: Connection refused Error - Linux
- How to Scan iPhone for Virus? Is Antivirus it really required? - HowTos
- Remove duplicate lines using Notepad++ - NotepadPlusPlus
- 3 Examples to read a text file line by line using java - Java
- How to install AWS CLI on Ubuntu - AWS
- Remove URL Forward Slash Before Single or Double quotes in php.ini - PHP
- MO229507 UK Europe users cannot access Microsoft 365 - SharePoint, OneDrive, Teams, Admin center, Planner, Yammer - Microsoft