I have a XML file like this (A.xml) :
<?xml version="1.0"?>
<RunParameters xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunParametersVersion>NextSeq_4_0_0</RunParametersVersion>
<ReagentKitSerialWasEnteredInBaseSpace>false</ReagentKitSerialWasEnteredInBaseSpace>
<ExperimentName>210913-RUN61-COCO</ExperimentName>
<PurgeConsumables>false</PurgeConsumables>
<MaxCyclesSupportedByReagentKit>92</MaxCyclesSupportedByReagentKit>
<ModuleName />
<ModuleVersion />
</RunParameters>
And I want to set a bash variable that contains the RUN61 port of the XML tag <ExperimentName>210913-RUN61-COCO</ExperimentName>. The tag value always has the structure
irrelevant-relevant-irrelevant
separated by dashes.
I tried with grep but whitout any good result:
runNumber=$(grep -o '<ExperimentName>.*</ExperimentName>' | cut -d '-' -f2 A.xml)
Do you know how to do it?
cut -d '-' -f2 A.xmldo?<ExperimentName>tags formatted. It it alwaysirrelevant-relevant-irrelevant? Is<ExperimentName>always under<RunParameters>? Can there be more than one<ExperimentName>?bashtag is relevant to the question here. It is standard text processing stuff. If its a shell script, the tags should beshell-script. The question is basically shell agnosticXX-YY-ZZ