Com o gnu grep
grep -B <number_lines> -A <number_lines> -n 'PATTERN' /path/to/files/*.log
por exemplo. para obter as 6 linhas acima da linha grep e 4 linhas depois:
grep -B 6 -A 4 -n 'PATTERN' /path/to/files/*.log
De man grep
Context Line Control
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching lines.
-B NUM, --before-context=NUM
Print NUM lines of leading context before matching lines.