sunos - Sed commad not working in sun solaris machine -
i have xml file in searching below pattern.
<serviceconfig id="554"> <comment>ecs_ocs_v1_0.0.0.7.32251@3gpp.org</comment> <maxcost>0.000000</maxcost> <maxcostlocalcurrency>true</maxcostlocalcurrency> <atomic>false</atomic> <tariffswitchhandling>external</tariffswitchhandling> <cdrattollfreeservice>false</cdrattollfreeservice> <bonusduringsession>false</bonusduringsession> <usermessagesstartofsession>true</usermessagesstartofsession> <usermessagesduringsession>true</usermessagesduringsession> <useaccumulatorstartvalues>false</useaccumulatorstartvalues> <validitytime factor="1">120</validitytime> <volume> <total preferredfactor="1024" preferred="500" minimumfactor="1000000" minimum="0"></total> </volume> <volumequotathreshold factor="1">0</volumequotathreshold> <sendquotaholdingtime>false</sendquotaholdingtime> <quotaholdingtime factor="1">0</quotaholdingtime> <sendquotaconsumptiontime>false</sendquotaconsumptiontime> <quotaconsumptiontime factor="1">0</quotaconsumptiontime> </serviceconfig>
block having open & close tags "serviceconfig" & in comment tag has "ecs_ocs_v1_0.0.0.7" string. purpose used below sed command.
sed -n '/<serviceconfig id=/ { :a /<\/serviceconfig/! { n; ba; }; /<comment>ecs_ocs_v1_0.0.0.7./ { p; b; }; }' serviceconfig.xml
this command working on linux system failing on sunos below error.
label long: /<serviceconfig id=/ { :a /<\/serviceconfig/! { n; ba; }; /<comment>ecs_ocs_v1_0.0.0.7./ { p; b; }; }
i not able understand cause of trouble. please help?
on solaris (most default setting and/of sed version), ;
not interpreted new line on gnu sed, use real new line especialy label , jump
sed -n '/<serviceconfig id=/ { :a /<\/serviceconfig/ !{ n ba } /<comment>ecs_ocs_v1_0.0.0.7./ { p b } }' serviceconfig.xml
or use several -e
action parameter
sed -n -e '/<serviceconfig id=/ {' -e ':a' -e '/<\/serviceconfig/ !{ n; ba' -e '}; /<comment>ecs_ocs_v1_0.0.0.7./ { p; b' -e'}' -e '}' serviceconfig.xml
Comments
Post a Comment