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
+6k Golang : Extract sub-strings
+4.4k Golang : How to pass data between controllers with JSON Web Token
+21.2k Golang : GORM create record or insert new record into database example
+14.5k Golang : How to check for empty array string or string?
+19.8k Golang : How to get struct tag and use field name to retrieve data?
+4.1k Javascript : How to show different content with noscript?
+6.8k Golang : Validate credit card example
+16.1k CodeIgniter/PHP : Create directory if does not exist example
+12k Golang : 2 dimensional array example
+6.9k CloudFlare : Another way to get visitor's real IP address
+12.2k Golang : Arithmetic operation with numerical slices or arrays example