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
+18.1k Golang : Simple client server example
+31.4k Golang : Calculate percentage change of two values
+5.6k Golang : Display advertisement images or strings on random order
+15.5k nginx: [emerg] unknown directive "ssl"
+13.5k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+18.6k Golang : Example for RSA package functions
+5k Unix/Linux : secure copying between servers with SCP command examples
+17.3k Golang : Capture stdout of a child process and act according to the result
+10k Golang : interface - when and where to use examples
+10.1k CodeIgniter : Load different view for mobile devices
+5.8k Golang : Detect words using using consecutive letters in a given string
+9.5k Golang : Temperatures conversion example