I’ve seen some examples of grepping lines before and after, but I’d like to ignore the middle lines.
So, I’d like the line five lines before, but nothing else.
Can this be done?
I’ve seen some examples of grepping lines before and after, but I’d like to
Share
OK, I think this will do what you’re looking for. It will look for a pattern, and extract the 5th line before each match.
basically how this works is it takes the first line, prints it, and then waits until it sees
^--$(the match separator used by grep), and starts again.