我有一个看起来像这样的 xml 文件:
<species compartment="compartment" id="alpha_dash_D_dash_glucose_dash_6P" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="six_dash_Phospho_dash_D_dash_gluconate" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="beta_dash_D_dash_Fructose_dash_6P2" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="beta_dash_D_dash_Glucose" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
我想用我自己的属性替换每个id
属性。我希望我的最终文件看起来像这样:
<species compartment="compartment" id="id1" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="id2" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="id3" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
</species>
<species compartment="compartment" id="id4" initialAmount="0" hasOnlySubstanceUnits="true" constant="false" boundaryCondition="false">
但是,该id
属性在文件的其他位置被引用:
<speciesReference constant="true" stoichiometry="1" species="alpha_dash_D_dash_glucose_dash_6P">
此行应更新为:
<speciesReference constant="true" stoichiometry="1" species="id1">
我尝试使用sed
with's/id="(*)"/id="$IdCOUNTER"/g'
但这使得所有id
属性都相同。我该如何解决这个问题?任何帮助表示赞赏,谢谢。