I have a collection of XML files in a standard format that I'd like to search to see if they match two strings. Here is the idea:<ELEMENT1>Dave</ELEMENT><DON'TCARE1>Blaa</DON'TCARE2><DON'TCARE2>Blaa2</DON'TCARE2><ELEMENT2>History</ELEMENT2>How can I match the content of ELEMENT1 and ELEMENT2 with egrep and return the filename that contains them?
Egrep multiple strings in an XML file
centos;grep;xml
With recent GNU grep built with recent PCRE:grep -Po '<(ELEMENT[12]>)\K.*?(?=</\1)'