Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 3
    See also To grep 20 characters after and before match Commented Jul 3, 2014 at 19:42
  • @StéphaneChazelas Thanks, it's the same question, but I'm looking for a better answer. ;) Commented Jul 3, 2014 at 19:47
  • 1
    If it is the same question, this kind of clarification might be better if asked in-comments on the original. Commented Jul 3, 2014 at 19:54
  • 1
    If the Q is a duplicate (it is), the other answers aren't good enough, and you can't find a way to make this a new question, the answer to "Is there a better way?" is No. @HalosGhost Adding a comment to an existing question looking for another answer is unlikely to solicit any response from anyone at all. Commented Jul 3, 2014 at 21:37
  • I'd say they're closely related but not duplicates (I answered both). The other one was looking at limiting the (multi-line) context offered by grep -A/B/C and was asking for color, file names and line numbers. This one is simpler as it only asks for context around a (or several) match within a line. Commented Jul 3, 2014 at 22:17