我正在尝试在大量 xml 文件中搜索缺少特定标记或该标记内的值为 0 的文件。
基本上,每个 xml 文件都有一个或多个 LIBRARY 标签,并且嵌套在这些标签内的是一个或多个 SECTION 标签,而这些标签内是一个或多个 SHELF 标签。在 SHELF 标签内应该有一个 BOOK 标签,其整数值不为零。
我需要查找此 BOOK 值为 0 或缺少 BOOK 的文件,但仅在每个 SECTION 的第一个SHELF 中。因此,如果多个 LIBRARY 标签内嵌套了多个 SECTION 标签,我需要检查每个 SECTION 中的第一个 SHELF。
<LIBRARY>
<SECTION>
<SHELF>
<BOOK>10000</BOOK>
</SHELF>
</SECTION>
</LIBRARY>
I am trying to write a Unix script to achieve this by searching each file in a given directory and returning a list of the files that match the pattern. I have been searching for a way to do it with sed, but I can't seem to find the solution to this particular problem. Also, the xml files are multi-line files, as shown above. Thank you guys for any help you can provide!