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
Lets check out some command
tasklist|find “notepad”
The below command searches for string in all the files ending .txt
find “string name” *.txt
findstr command
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
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
/I : Searches are case insensitive
findstr /I “abcd” test.txt
/V : Print the file if it does not have that string
findstr /V “ABCD” test.txt
/N : Print the line number also
findstr /N “ABCD” test.txt
Powershell select-string command
Some examples
- 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
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
- Window Grep (Paid)
- PowerGrep (Paid)
- Gnu Grep( Free)
- AstaGrep(Paid)
0 comments:
Post a Comment