Findstr command the Grep equivalent for Windows
It has been a while since I use a computer with Windows Operating System. However, I have no choice today since I'm working on a computer provided by client.
In the course of understanding the legacy codes....I need to search the legacy source codes with the grep command. Wait, there's no grep command in Windows!
A friend introduces this nifty tool - findstr
. The grep equivalent command in Windows world.
For example :
In Linux
$ ls -ls | grep filename
In Windows
c:\> dir | findstr filename
For multiple strings search with case insensitive example :
In Linux
$ ls -ls | grep -iE "testdata|lifo"
In Windows - empty space to replace pipe |
for multiple strings
c:\> dir | findstr -i "testdata lifo"
And to search through a list of file example
In Linux
$ grep searchtag -lr /path/directory
In Windows
c:\> findstr /M searchtag c:\directory\*
Hope this helps!
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.9k Golang : Get SPF and DMARC from email headers to fight spam
+22.3k Golang : Check if element exist in map
+15.8k Golang : Get number of CPU cores
+6k Golang : Get environment variable
+9.8k Golang : Natural string sorting example
+2k Golang : Fix go-cron set time not working issue
+7.2k How to show different content from website server when AdBlock is detected?
+28.8k Golang : Remove characters from string example
+8.7k Golang : Sort and reverse sort a slice of floats
+6.2k Golang : Process json data with Jason package
+3.9k MariaDB/MySQL : Form select statement or search query with Chinese characters
+6.3k Golang : How to stop user from directly running an executable file?