2

我有这个 xml 文件:

<?xml version="1.0"?>
<RunInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2">
  <Run Id="130514_M01481_0011_000000000-A3F7W" Number="10">
    <Flowcell>000000000-A3F7W</Flowcell>
    <Instrument>M01481</Instrument>
    <Date>130514</Date>
    <Reads>
      <Read NumCycles="151" Number="1" IsIndexedRead="N" />
      <Read NumCycles="8" Number="2" IsIndexedRead="Y" />
      <Read NumCycles="8" Number="3" IsIndexedRead="Y" />
      <Read NumCycles="151" Number="4" IsIndexedRead="N" />
    </Reads>
    <FlowcellLayout LaneCount="1" SurfaceCount="2" SwathCount="1" TileCount="14" />
  </Run>
</RunInfo>

我需要编写一个循环遍历“Reads”并提取 IsIndexedRead="N" 和 IsIndexedRead="Y" 的 NumCycles 的 shell 脚本。我在这个命令中使用了 xmllint:

xmllint --xpath 'string(//Read/@NumCycles)' RunInfo.xml

这给了 151,但我需要循环读取。有人知道更好的方法吗?谢谢

4

1 回答 1

3

xmllint --xpath '//Read[@IsIndexedRead = "Y"]/@NumCycles' RunInfo.xml | grep -o '[0-9]\+'

8
8

xmllint --xpath '//Read[@IsIndexedRead = "N"]/@NumCycles' RunInfo.xml | grep -o '[0-9]\+'

151
151
于 2013-05-23T11:17:11.790 回答