我想从下面添加的文件中删除下面的部分。
1.无法从文件中删除此属性credentials.admin.adapters
1.删除同一行中的其他属性。
1.如何在同一行中的< >
字符之间添加内容。
<!--<UndefineProperty name="credentials.admin.adapters"/>-->
<!--<AddToProperty name="credentials.admin.adapters"
value="com.Ldap^cn=Manager^encrypted.com.Ldap.cn=admin"/>-->
<Property name="credentials.admin.adapters" overridable="true"
targetFile="Credentials.txt"
value="com.Ldap^id=proxy"/>
<!--<UndefineProperty name="credentials.admin.adapters"/>
<AddToProperty name="credentials.admin.adapters"
value="com.Ldap^cn=admin^encrypted.com.Ldap.cn=admin"/> -->
新配置文件
<!--<UndefineProperty name="credentials.admin.adapters"/>-->
<!--<AddToProperty name="credentials.admin.adapters"
value="com.Ldap^cn=Manager^encrypted.com.Ldap.cn=admin"/>-->
<Property name="credentials.admin.adapters" overridable="true"
targetFile="Credentials.txt"
value="com.Ldap^id=proxy"/>
<Property name="pom.dbUser" overridable="true" targetFile="db.properties"
value="NM"/>
<Property name="pom.jdbc.host" overridable="true" targetFile="db.properties"
value="0038.rds.amazonaws.com"/>
<Property name="pom.dbPassword" overridable="true" targetFile="db.properties"
value="encrypted.pom.dbPassword"/>
<Property name="pom.serviceName" overridable="true" targetFile="db.properties"
value="rds.amazonaws.com:10:0038"/>
<Property name="pom.jdbc.service" overridable="true" targetFile="db.properties"
value="0038"/>
<Property name="pom.jdbc.port" overridable="true" targetFile="db.properties"
value="10"/>
<ConfigurationRef xlink:href="utilities/configurator.xconf"/>
<ConfigurationRef xlink:href="owl.xconf"/>
<ConfigurationRef xlink:href="ser.xconf"/>
<!--<UndefineProperty name="credentials.admin.adapters"/>
<AddToProperty name="credentials.admin.adapters"
value="com.Ldap^cn=admin^encrypted.com.Ldap.cn=admin"/> --><Property
name="com.distproc.credential" overridable="true"
targetFile="distproc.properties"
value=""/>
</Configuration>
我试了试下面:
sed -i '/value=/N; s/\n\s*/ /g' newconf.txt
sed -i "/credentials.admin.adapters/d" newconf.txt
但是上面的代码也删除了其他人的属性。
我想要以下输出:
<Property name="pom.dbUser" overridable="true" targetFile="db.properties" value="NM"/>
<Property name="pom.jdbc.host" overridable="true" targetFile="db.properties" value="0038.rds.amazonaws.com"/>
<Property name="pom.dbPassword" overridable="true" targetFile="db.properties" value="encrypted.pom.dbPassword"/>
<Property name="pom.serviceName" overridable="true" targetFile="db.properties" value="rds.amazonaws.com:10:0038"/>
<Property name="pom.jdbc.service" overridable="true" targetFile="db.properties" value="0038"/>
<Property name="pom.jdbc.port" overridable="true" targetFile="db.properties" value="10"/>
<ConfigurationRef xlink:href="utilities/configurator.xconf"/>
<ConfigurationRef xlink:href="owl.xconf"/>
<ConfigurationRef xlink:href="ser.xconf"/>
<Property name="com.distproc.credential" overridable="true" targetFile="distproc.properties" value=""/>
</Configuration>
删除以下行:
<!--<UndefineProperty name="credentials.admin.adapters"/>-->
<!--<AddToProperty name="credentials.admin.adapters" value="com.Ldap^cn=Manager^encrypted.com.Ldap.cn=admin"/>-->
<Property name="credentials.admin.adapters" overridable="true" targetFile="Credentials.txt" value="com.Ldap^id=proxy"/>
<!--<UndefineProperty name="credentials.admin.adapters"/>
<AddToProperty name="credentials.admin.adapters" value="com.Ldap^cn=admin^encrypted.com.Ldap.cn=admin"/> -->
2条答案
按热度按时间wgxvkvu91#
使用
sed
低于不稳定输出:
dbf7pr2w2#
一个大的
FS
和两个对gsub()
的调用就足够了:=