I have an xml file. I need to print five lines before the matched text.
There may be multiple matches. I am using following awk command which is returning only one row.
awk '/<\/ABC>/' file.xml
returns
<ABC>Some Text1</ABC>
<ABC>Some Text2</ABC>
<ABC>Some Text3</ABC>
Expected:
... previous 4 lines ...
<ABC>Some Text1</ABC>
... previous 4 lines ...
<ABC>Some Text2</ABC>
... previous 4 lines ...
<ABC>Some Text3</ABC>
Cannot use grep -B
as per in Solaris:
grep: illegal option -- B grep: illegal option -- 2 Usage: grep -hblcnsviw pattern file