Linux 在awk中重置标志
我有以下使用awk的函数:Linux 在awk中重置标志,linux,shell,scripting,awk,Linux,Shell,Scripting,Awk,我有以下使用awk的函数: getStageMode() { targ=$1; shift mode=$(awk ' /[<]app-deployment/{a=1} a && /[<]name[>]'"${targ}[<]"'/{n=1} a && n && /[<]staging-mode[>]/{ sub(/[<]st
getStageMode() {
targ=$1; shift
mode=$(awk '
/[<]app-deployment/{a=1}
a && /[<]name[>]'"${targ}[<]"'/{n=1}
a && n && /[<]staging-mode[>]/{
sub(/[<]staging-mode[>]/,"", $0)
sub(/[<]\/staging-mode[>]/,"",$0)
print $0
exit
}
{print "n=" n }
' "${@}")
echo $mode
}
getStageMode(){
targ=1美元;班次
模式=$(awk'
/[/[重置n的条件是什么?与
/[<]\/app-deployment/{a=0; n=0}
getStageMode() {
targ=$1; shift
mode=$(awk '
/[<]\/app-deployment/{a=0; n=0}
/[<]app-deployment/{a=1}
a && /[<]name[>]'"${targ}[<]"'/{n=1}
a && n && /[<]staging-mode[>]/{
sub(/[<]staging-mode[>]/,"", $0)
sub(/[<]\/staging-mode[>]/,"",$0)
print $0
exit
}
{print "n=" n }
' "${@}")
echo $mode
}
<app-deployment>
<name>gr2</name>
<target>AdminServer</target>
<module-type>ear</module-type>
<source-path>/u01/app/wls1035_homes/wls1035_9999/grc864</source-path>
<security-dd-model>DDOnly</security-dd-model>
<staging-mode>nostage</staging-mode>
</app-deployment>
<app-deployment>
<name>gr3</name>
<target>AdminServer</target>
<module-type>ear</module-type>
<source-path>/u01/app/wls1035_homes/wls1035_9999/grc864</source-path>
<security-dd-model>DDOnly</security-dd-model>
</app-deployment>