0

I want to extract the value of clusterName="BYSL_Dev" from the below line

<xmi:id="test.cim " name="test" clusterName="BYDev" developmentMode="false" parallelStartEnabled="true"> <stateManagement xmi:id="StateManageable_1257282383109" initialState="START"/>
0

For http or xml files, a tool like sgrep works much better than sed or awk. Use e.g.

sgrep '"clusterName=\""__"\""' your-file.xml

You can refine the matching if you want to restrict it to the inside of certain tags etc.

  • Thanks for your response , But I don't have sgrep installed in my system . – Manish Oct 14 '16 at 15:43
  • Do you know any other way like using AWK or SED ,Above Command did not worked for me – Manish Oct 14 '16 at 15:44
  • When I Ran command I got – Manish Oct 14 '16 at 20:01
0

This sed works for me:

sed -r 's/.*name=".*" (.*") d.*/\1/' cluster 
clusterName="BYSL_Dev"

Where cluster is this file:

cat cluster 
<xmi:id="manish.cim " name="manish" clusterName="BYSL_Dev" developmentMode="false" parallelStartEnabled="true"> <stateManagement xmi:id="StateManageable_1257282383109" initialState="START"/>
  • I tried this but it says – Manish Oct 14 '16 at 20:03
  • I tried this but it says sed: illegal option --r – Manish Oct 14 '16 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.