I have a very long XML file that has some repeating sections. I want to find the line number which is the closest occurrence of string B on string A. Say I have many instances of:
<section> ... <entry> <key>key-im-looking-for</key> ... </entry> ... <type>org.apache.whatever.package</type> ... </section>
I want to find the line number that contains
which is nearest to (or contained in same section)
<type>org.apache.whatever.package</type> as the search term, using either grep, awk or sed.