我需要更改这段代码:
NR==FNR {
cert = (NR==1 ? "" : cert ORS) $0
next
}
sub(/<named-connections>.*/,"") {
beg = $0 "<named-connections>"
inCert = 1
}
inCert {
if ( sub(/.*<[\/]named-connections>/,"") ) {
end = "</named-connections>" $0
print beg cert end
inCert = 0
}
next
}
{ print }
为了,而不是改变标签里面的内容
<named-connections>
,只改变连接标签
<named-connections>
<named-connection caption='xyz' name='05mqr9a0muzjns11387v9142owuo'>
<connection authentication='RDBMS' class='oracle' one-time-sql='' oracle.net.ssl_version='' port='10000' schema='PARSE' server='xyz.z' server-oauth='' service='abc' sslmode='require' username='DBABA' workgroup-auth-mode='prompt' />
</named-connection>
</named-connections>
有什么想法吗?
我试过下面的代码但没有成功:
NR==FNR {
cert = (NR==1 ? "" : cert ORS) $0
next
}
sub(/<named-connection[^>]*>.*/,"") {
beg = $0 "<named-connection[^>]*>"
inCert = 1
}
inCert {
if ( sub(/.*<[\/]named-connection[^>]*>/,"") ) {
end = "</named-connection[^>]*>" $0
print beg cert end
inCert = 0
}
next
}
{ print }