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
+11.1k Golang : Listen and Serve on sub domain example
+5k Golang : Extract XML attribute data with attr field tag example
+7.9k Golang : Generate random Chinese, Japanese, Korean and other runes
+12.3k Golang : Convert spaces to tabs and back to spaces example
+4.7k PHP : Get client IP address
+12.8k Golang : ROT47 (Caesar cipher by 47 characters) example
+29.8k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+5.3k CodeIgniter : form input set_value cause " to become & quot
+8.4k Golang : How to protect your source code from client, hosting company or hacker?
+15.7k Golang : XML to JSON example
+10.6k Golang : Split strings into command line arguments
+18.5k Golang : Set or Add HTTP Request Headers