grep is not recognized as an internal or external in windows

I am trying to run this line

 scholar.py --txt-globals --author "albert einstein" | grep '\[G\]' | grep Results

In the CMD, but I confront this error. I know grep is for UNIX but how can I run this line in windows? I have windows 7.


Solution 1:

You can install all these nice UNIX commands with Cygwin (https://www.cygwin.com/).

Solution 2:

CMD does not have grep like unix does. This applies to many commands, such as sed, awk, sudo, cat...etc.

However, if you use PowerShell instead of cmd, it has a Select-String cmdlet which will allow you to get similar results.

scholar.py --txt-globals --author "albert einstein" | Select-String '[G]' | Select-String 'Results'

I haven't tested the Regex. But if Select-String isn't giving you the required results you can install Grep for Windows.