You could do this with grep or ack or ag:
grep bar -A 5 -B 5 files... | grep foo
-A n prints n lines following the match (bar) and -B n prints n lines before the match.