Ruby equivalent to "grep -C 5" to get context of lines around the match?
Posted
by wonderfulthunk
on Stack Overflow
See other posts from Stack Overflow
or by wonderfulthunk
Published on 2010-05-03T19:48:54Z
Indexed on
2010/05/03
20:48 UTC
Read the original article
Hit count: 201
I've searched for this a bit but I must be using the wrong terms - does ruby have a way to grep for a string/regex and also return the surrounding 5 lines (above and below)? I know I could just call "grep -C 5 ..."
or even write my own method, but it seems like something ruby would have and I'm just not using the right search terms.
© Stack Overflow or respective owner