Existe soluções baseado em _javascript_, python, php, perl, etc que acredito sejam até melhores
BEGIN { ok = 0 }
/<tagy>/,/<\/tagy>/ {
linha[++j] = $0
if ($0 ~ /<tagz>true/) { ok = 1 }
if ($0 ~ /<\/tagy>/ && ok == 1) {
for (i=1;i<=length(linha);i++) { print linha[i] }
ok = 0
split("", linha)
}
}' arquivo.xml
Em outra resposta foi sugerido o xmllint + xpath, confesso que o pouco que usei não tive bons resultados, mas acredito que seja por não dominar adequadamente as ferramentas. Se tiver tempo, recomendo que pesquise sobre elas.
[]'s
Itamar