Using grep on Windows to recursively find a C++ class definition in a header

There are so many grep examples out there but if you want to use grep on Windows to find something recursively in just one file type it can get a bit tricky.  Here is the quick 2 step process:

  1. get grep. you can find it here http://gnuwin32.sourceforge.net/packages/grep.htm

  2. add path to grep into your PATH by opening the Windows start menu and typing “env” then selecting Edit environment variables
    Windows Environment Variables
  3. open a command prompt by opening the Windows start menu and typing “cmd” then press Enter
  4. enter a grep command.  for example, to find a class definition in all .h files it might be:
    grep -r --include=*.h "class WhereIsThatClass" *

Author: sirspot

I write software, love my wife and kids, do various house projects, play video games when I have time, and could use a little more sleep