I have a file which is having some variables, I want to copy each line from this to other file except for the lines which has the type=Password .
here is the sample file.
<Environment xsi:type="amxdata:Environment" name="@AMX_ENVIRONMENT_NAME@">
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="FF_JDBC_USERNAME" type="String" value="@SVAR_ENV_JDBC_USERNAME@" />
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="FF_JDBC_PASSWORD" type="Password" value="@SVAR_ENV_JDBC_PASSWORD@" />
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="MON_JMS_USERNAME" type="String" value="@MON_EMS_USER@" />
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="MON_JMS_PASSWORD" type="Password" value="@MON_EMS_PASSWORD@" />
</Environment>
<Environment xsi:type="amxdata:Environment" name="@AMX_ENVIRONMENT_NAME@">
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="FF_JDBC_USERNAME" type="String" value="@SVAR_ENV_JDBC_USERNAME@" />
<SVar xsi:type="amxdata_base:SubstitutionVariable" name="MON_JMS_USERNAME" type="String" value="@MON_EMS_USER@" />
</Environment>
This is how I would accomplish your task. It reads in.xml
into property xml-content
excluding the lines with type="Password"
and prints the new contents into out.xml
.
<target name="strip-passwords">
<loadfile property="xml-content" srcFile="in.xml" >
<filterchain>
<linecontainsregexp negate="true">
<regexp pattern="\Qtype="Password"\E"/>
</linecontainsregexp>
</filterchain>
</loadfile>
<echo message="${xml-content}" file="out.xml"/>
</target>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.