Grep equivalent in Windows to search text

We use grep command to search for strings in the Unix Operation system. Now the same things on Windows can be done using these three free tools. These tools can do many work same as Grep command.

Find command

Find command in windows: Grep equivalent of windows

Lets check out some command

tasklist|find “notepad”

Find command in windows

The below command searches for string in all the files ending .txt

find “string name” *.txt

findstr command

findstr command in window: grep equivalent for windows

It is quite powerful search command like grep and we can use regular expression with it
We have a text file,which we will use in our examples

/M : Print only those lines which does not match the string

findstr /M   “^W” test.txt

findstr command in windows example

/I : Searches are case insensitive

findstr /I   “abcd” test.txt

findstr command example

/V : Print the file if it does not have that string

findstr /V   “ABCD” test.txt

findstr command example -v

/N : Print the line number also

findstr /N   “ABCD” test.txt

Powershell select-string command

powershell select-string command

Some examples

  1. The below command prints all the lines except the line which contain the pattern
PS C:\test\> Select-String -Path “test.txt” -Pattern “abcd” -NotMatch

select-string command in powershell  in windows

2)The below command prints all the lines which exactly matches with pattern(Case sensitive)

PS C:\test\> Select-String -Path “test.txt” -Pattern “abcd” -CaseSensitive

3) If you dont to print the file as search pattern in one file,then we can use Get-content

PS C:\test\> Get-content test.txt|Select-String -Pattern “abcd”

Others tool for grep like search on windows

These are packages which can be installed on windows

  1. Window Grep (Paid)
  2. PowerGrep  (Paid)
  3. Gnu Grep( Free)
  4. AstaGrep(Paid)

Leave a Reply