This question already has an answer here:

I have a compressed JS code and I want to find a pattern, but since the file is compresses, it has only a line, and the match pattern is all the file. The output is too much large.

grep -r "myPattern"

I can do:

grep -r --only-matching "myPattern"

but in this way, I get just the matching characters, and I need more information.

Ideally, I'd want the matching characters and a number defined of characters before and after those matching characters.

Any suggestion?

marked as duplicate by jofel, Anthon, rahmu, manatwork, Thomas Nyman Oct 22 '13 at 12:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.