How do I Search string from command output and print next two lines from the output.
Below is code:
a = """
Some lines I do not want
----- -------- --
I need this line
I need this line also
Again few lines i do not want
"""
for line in a.split("\n"):
if line.startswith("----"):
print "I need this line"
print "I need this line also"
What I am doing in above code is I am checking if line starts with "----" and This works fine. Now How do i print exactly two lines after line starts with "----". In this example code print, " I need this line and I need this line also"