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
+10k Golang : Check if user agent is a robot or crawler example
+8k Swift : Convert (cast) String to Float
+8.5k PHP : How to parse ElasticSearch JSON ?
+11k Golang : Removes punctuation or defined delimiter from the user's input
+8.2k Golang : Metaprogramming example of wrapping a function
+23.7k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+12.9k Golang : Convert int(year) to time.Time type
+16.6k Golang : Get IP addresses of a domain name
+12.7k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+11.5k Golang : Delay or limit HTTP requests example
+17.3k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+9.6k Golang : Extract or copy items from map based on value