gpsOutEnabled =“ FALSE”
smokeDetector =“ FALSE”
/>
siteName =“ Alzey002”
logicalName =“ FXU046”
>
ectorNumber =“ 1”
latitude =“ 4635826”
latHemisphere =“ NORTH”
经度=“ 377963”
geoDatum =“ DHDN-”
beamDirection =“ 060”
高度=“ 3000”
ectorGroup =“-1”
/>
ectorNumber =“ 2”
latitude =“ 4635826”
latHemisphere =“ NORTH”
经度=“ 377963”
geoDatum =“ DHDN-”
beamDirection =“ 140”
高度=“ 3000”
ectorGroup =“-1”
/>
ectorNumber =“ 3”
latitude =“ 4635826”
latHemisphere =“ NORTH”
经度=“ 377963”
geoDatum =“ DHDN-”
beamDirection =“ 300”
高度=“ 3000”
ectorGroup =“-1”
/>
radioBuildingBlock =“ RBB12_1A”
cpriLineRate =“ Ox4”
ectorNumber =“ 1”
primaryPortId =“ BU1_A”
ectorSequenceNumber =“ 1”
rruInstalled =“否”
/>
radioBuildingBlock =“ RBB12_1A”
cpriLineRate =“ Ox4”
ectorNumber =“ 2”
primaryPortId =“ BU1_B”
ectorSequenceNumber =“ 1”
rruInstalled =“否”
/>
radioBuildingBlock =“ RBB12_1A”
cpriLineRate =“ Ox4”
ectorNumber =“ 3”
primaryPortId =“ BU1_C”
ectorSequenceNumber =“ 1”
rruInstalled =“否”
/>
ectorNumber =“ 1”
tmaType =“ NONE”
tmaType2 =“ NONE”
tmaType3 =“ NONE”
typeOfRet =“ RETU”
typeOfRet2 =“ NONE”
typeOfRet3 =“ NONE”
riuInstalled =“否”
riuInstalled2 =“否”
currentLowSupervision_A =“ ON”
currentLowSupervision_B =“ ON”
currentLowSupervision_C =“ ON”
currentLowSupervision_D =“ ON”
/>
ectorNumber =“ 2”
tmaType =“ NONE”
tmaType2 =“ NONE”
tmaType3 =“ NONE”
typeOfRet =“ RETU”
typeOfRet2 =“ NONE”
typeOfRet3 =“ NONE”
riuInstalled =“否”
riuInstalled2 =“否”
currentLowSupervision_A =“ ON”
currentLowSupervision_B =“ ON”
currentLowSupervision_C =“ ON”
currentLowSupervision_D =“ ON”
/>
ectorNumber =“ 3”
tmaType =“ NONE”
tmaType2 =“ NONE”
tmaType3 =“ NONE”
typeOfRet =“ RETU”
typeOfRet2 =“ NONE”
typeOfRet3 =“ NONE”
riuInstalled =“否”
riuInstalled2 =“否”
currentLowSupervision_A =“ ON”
currentLowSupervision_B =“ ON”
currentLowSupervision_C =“ ON”
currentLowSupervision_D =“ ON”
/>
ectorNumber =“ 1”
ennaType =“ 2”
ennaType2 =“ 0”
ennaType3 =“ 0”
mechanicalTilt =“ 0”
mechanicalTilt2 =“ 0”
mechanicalTilt3 =“ 0”
electricalTilt =“ 30”
band =“ 1”
fqBandHighEdgeBranchA =“ 21250”
fqBandLowEdgeBranchA =“ 21100”
fqBandHighEdgeBranchB =“ 21250”
fqBandLowEdgeBranchB =“ 21100”
fqBandHighEdgeBranchC =“”
fqBandLowEdgeBranchC =“”
fqBandHighEdgeBranchD =“”
fqBandLowEdgeBranchD =“”
fqBandHighEdgeBranchE =“”
fqBandLowEdgeBranchE =“”
fqBandHighEdgeBranchF =“”
fqBandLowEdgeBranchF =“”
dlFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ectorOutputPower =“ 60”
beamDirection =“ 060”
beamDirection2 =“ 000”
beamDirection3 =“ 000”
/>
ectorNumber =“ 2”
ennaType =“ 2”
ennaType2 =“ 0”
ennaType3 =“ 0”
mechanicalTilt =“ 0”
mechanicalTilt2 =“ 0”
mechanicalTilt3 =“ 0”
electricalTilt =“ 0”
band =“ 1”
fqBandHighEdgeBranchA =“ 21250”
fqBandLowEdgeBranchA =“ 21100”
fqBandHighEdgeBranchB =“ 21250”
fqBandLowEdgeBranchB =“ 21100”
fqBandHighEdgeBranchC =“”
fqBandLowEdgeBranchC =“”
fqBandHighEdgeBranchD =“”
fqBandLowEdgeBranchD =“”
fqBandHighEdgeBranchE =“”
fqBandLowEdgeBranchE =“”
fqBandHighEdgeBranchF =“”
fqBandLowEdgeBranchF =“”
dlFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ectorOutputPower =“ 60”
beamDirection =“ 140”
beamDirection2 =“ 000”
beamDirection3 =“ 000”
/>
ectorNumber =“ 3”
ennaType =“ 2”
ennaType2 =“ 0”
ennaType3 =“ 0”
mechanicalTilt =“ 0”
mechanicalTilt2 =“ 0”
mechanicalTilt3 =“ 0”
electricalTilt =“ 60”
band =“ 1”
fqBandHighEdgeBranchA =“ 21250”
fqBandLowEdgeBranchA =“ 21100”
fqBandHighEdgeBranchB =“ 21250”
fqBandLowEdgeBranchB =“ 21100”
fqBandHighEdgeBranchC =“”
fqBandLowEdgeBranchC =“”
fqBandHighEdgeBranchD =“”
fqBandLowEdgeBranchD =“”
fqBandHighEdgeBranchE =“”
fqBandLowEdgeBranchE =“”
fqBandHighEdgeBranchF =“”
fqBandLowEdgeBranchF =“”
dlFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchA =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederAttenuationBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
dlFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ulFeederDelayBranchB =“ 0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1”
ectorOutputPower =“ 60”
beamDirection =“ 300”
beamDirection2 =“ 000”
beamDirection3 =“ 000”
/>
ectorNumber =“ 1”
AntennaSupervisionBranchA =“ 10”
AntennaSupervisionBranchB =“ 10”
AntennaSupervisionBranchC =“ 0”
AntennaSupervisionBranchD =“ 0”
AntennaSupervisionBranchE =“ 0”
AntennaSupervisionBranchF =“ 0”
/>
ectorNumber =“ 2”
AntennaSupervisionBranchA =“ 10”
AntennaSupervisionBranchB =“ 10”
AntennaSupervisionBranchC =“ 0”
AntennaSupervisionBranchD =“ 0”
AntennaSupervisionBranchE =“ 0”
AntennaSupervisionBranchF =“ 0”
/>
ectorNumber =“ 3”
AntennaSupervisionBranchA =“ 10”
AntennaSupervisionBranchB =“ 10”
AntennaSupervisionBranchC =“ 0”
AntennaSupervisionBranchD =“ 0”
AntennaSupervisionBranchE =“ 0”
AntennaSupervisionBranchF =“ 0”
/>
carrierAllocationMode =“ Flexible”
>
ectorNumber =“ 1”
>
cellNumber =“ 1”
cellCreated =“ YES”
cellIdentity =“ 461”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 2”
cellCreated =“ YES”
cellIdentity =“ 465”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 3”
cellCreated =“ YES”
cellIdentity =“ 468”
cellRange =“ 35000”
baseBandPoolId =“ 1”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
ectorNumber =“ 2”
>
cellNumber =“ 1”
cellCreated =“ YES”
cellIdentity =“ 462”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 2”
cellCreated =“ YES”
cellIdentity =“ 466”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 3”
cellCreated =“ YES”
cellIdentity =“ 469”
cellRange =“ 35000”
baseBandPoolId =“ 1”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
ectorNumber =“ 3”
>
cellNumber =“ 1”
cellCreated =“ YES”
cellIdentity =“ 463”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 2”
cellCreated =“ YES”
cellIdentity =“ 467”
cellRange =“ 35000”
baseBandPoolId =“ 2”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
cellNumber =“ 3”
cellCreated =“ YES”
cellIdentity =“ 460”
cellRange =“ 35000”
baseBandPoolId =“ 1”
numberOfTxBranches =“ 1”
numberOfRxBranches =“ 2”
/>
最佳答案
用sed执行此操作不是一个好主意,因为您必须将shell变量替换为sed代码,从而导致代码注入问题(如果该变量包含斜杠,&
或sed认为其他特殊字符在上下文)。
使用awk,您可以执行以下操作:
awk -v runas="$RUN_AS" '/JOBNAME="NSVN1999"/ { sub(/RUN_AS="[^"]*"/, "RUN_AS=\"" runas "\"") } 1' filename.xml
或同时将工作名称作为变量,
awk -v runas="$RUN_AS" -v jobname="$JOBNAME" '$0 ~ "JOBNAME=\"" jobname "\"" { sub(/RUN_AS="[^"]*"/, "RUN_AS=\"" runas "\"") } 1' filename.xml
但是,使用面向纯文本的工具来编辑XML并不是一个好主意-例如,您不会指望XML处理工具会损坏,因为有人会在良性的地方插入换行符。如果您修复了XML(在给定的示例代码中,在第一个
JOBISN=
标记中将JOBISN=""
替换为JOB
,然后关闭FOLDER
标记以使其生效),则可以使用适当的XML工具,例如:xmlstarlet ed -u '//JOB[@JOBNAME="NSVN1999"]/@RUN_AS' -v "$RUN_AS" filename.xml
其中,
xmlstarlet
是一个XPath表达式,它选择所有//JOB[@JOBNAME="NSVN1999"]/@RUN_AS
属性为RUN_AS
的JOB
节点的JOBNAME
属性。关于linux - 从xml文件,bash脚本中提取值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28581049/