Suponho que você esteja usando um sistema * nix. Se você quer apenas os arquivos na pasta atual, faça
$ grep -C 3 foo *
bar.txt-This is line one
bar.txt:This is line two, which contains foo
bar.txt-This is line 3
Se você também quiser recorrer a subpastas, use
grep -rC 3 foo
Detalhes:
grep, egrep, fgrep, rgrep - print lines matching a
pattern
-C NUM, -NUM, --context=NUM
Print NUM lines of output context. Places a
line containing a group separator (--) between
contiguous groups of matches. With the -o or
--only-matching option, this has no effect and
a warning is given.
-R, -r, --recursive
Read all files under each directory,
recursively; this is equivalent to the -d
recurse option.