I'm working with XML files, each of which could be dozens of lines long. There are literally hundreds of these files, all over a directory structure. Yes, it is Magento.
I need to find the file that has the
<foo><bar><boom><bang> element. A
<boom><bang> tag could be defined under other tags, so I need to search for the full path not just the end tag or tags. There could be dozens of lines between each tag, and other tags between them:
<foo> <hello_world> ... 50 lines .... </hello_world> <bar> <giraffe> ... 50 lines .... </giraffe> <boom> <bang>Vital information here</bang> </boom> </bar> </foo>
What is the elegant, *nix way of searching for the file that defines
<foo><bar><boom><bang>? I'm currently on an up-to-date Debian-derived distro.
This is my current solution, which is far from eloquent:
$ grep -rA 100 foo * | grep -A 100 bar | grep -A 100 boom | grep bang | grep -E 'foo|bar|boom|bang'