Saturday, 24 August 2013

Print Matching line and nth line from the matched line

Print Matching line and nth line from the matched line

I am trying to print the matched line and the 4th line from the matched
line (line containing the expression I am searching for).
I have been using the following code: sed -n 's/^[ \t]*//; /img
class=\"devil_icon/,4p' input.txt
But this only prints the matched line.
This prints only the 4th line. awk 'c&&!--c;/img class=\"devil_icon/{c=4}'
input.txt
I need to print both the matched line and the 4th line only.

No comments:

Post a Comment