I wanted a way to search through the ~200 themes we have on WordPress.com to find out which ones registered sidebar areas for the home page, and this is what I came up with:
find . -print0 |xargs -0 grep 'register_sidebar' -s -A 2 |grep 'home\|front' |more
That’d have to be customized to fit other circumstances (like using -B if you want to search lines before the initial term), of course.