grep – How to hightlight text search results like google?

The following is one way to hightlight grep results with n context characters. And each match is broken into a line.


Google is more intelligent, such that it shows the match separated by .... Also, sometimes it respect sentence boundary. Is there any code that grep text by hightlight matches similar to the google way?

لینک منبع