9

Grep with context about matched lines in Windows

view full story
linux-howto

http://superuser.com – I want to search in files, recursively, with a pattern for the filename, for a given string, in a Windows 7 command prompt. I am familiar with Unix. So far, findstr /spin /c:"main" *.py is a good replacement for find . -name "*.py" -exec grep -nH "main" {} \; Now, if I want to show some context for each matched line (some lines before and after), how would I do that? The Unix command is find . -name "*.py" -exec grep -nH -B 2 -A 2 "main" {} \; As of now, I used MinGW, and I guess UnxUtils, GnuWin32, etc. may work, but I am looking for a native Windows command or sequence/pipe of comm (HowTos)