I have an XML file in unix directory. I would like to search for some character if that is present, then grep the text located 3 lines before this matched line,.
Here is My File: (abc.xml)
<task Col="5" Object="BCD">
<checkpoint TcpOn="0"/>
<after ActFlg="0"/>
</task>
<task Col="6" Object="ABCD">
<checkpoint TcpOn="0"/>
<after ActFlg="1"/>
</task>
<task Col="7" Object="ABCDE">
<checkpoint TcpOn="0"/>
<after ActFlg="1"/>
</task>
Unix Code:
grep -i 'actflg="1"' abc.xml
Current Answer: This is returning the line where it is located.
<after ActFlg="1"/>
<after ActFlg="1"/>
What i Want is : (i want to do a further grep to display output as follows if actflg="1" is found...)
<task Col="6" Object="ABCD">
<task Col="7" Object="ABCDE">