Home » General » windows grep equivalent to search text

windows grep equivalent to search text

We use grep command to search for strings in the Unix Operation system. Now when we work on Windows, we don’t have grep command in Windows, So We often look for grep equivalent in windows. This problem can be solved on Windows using these three free tools. These tools can do many works same as Grep command. These are a powerful tool and every body working on windows should be familiar with them.Let’s do deep dive into these

Find command

Find command is great tool in window and we can do many things with it. We look for option available with Find command using help find

windows grep equivalent

Lets check out some command

The below command grep for notepad in the tasklist(Process running on the system) of the window system

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

Another tool which is grep equivalent in windows is the findstr command.We look for option available with findstr command using help findstr

findstr command in window: grep equivalent for windows

It is quite a 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

windows grep command equivalent

/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
grep equivalent windows
grep equivalent windows

/N : Print the line number also

findstr /N   "ABCD" test.txt

Powershell select-string command

This is another grep equivalent in windows .

See also  Helpful Free Courses on Udemy
powershell select-string command | windows cmd grep equivalent

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
grep equivalent 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 don’t want to print the filename 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)

I hope you like this post on windows grep equivalent and this will help in search text in windows in batch files

Also Reads
grep command in Unix : Grep command Means – globally search regular expression.grep command in unix is used for searching text,regular expression across multiple files
CPU vs Core Vs Socket : Find out what is CPU vs Core Vs Socket, difference and how to find them in windows using different command in easy manner
change password on Remote desktop : Find out how to change change password on Remote desktop in a easy manner,how to open remote desktop connection and shortcuts also
Free Remote Desktop Manager : List of free remote desktop manager for easy working with multiple server to RDP
https://en.wikipedia.org/wiki/Grep

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top