在Apache Ant中,我想替换文件中的字符串,但仅用于特定的字符串出现。我有一个for循环,我想只替换循环编号出现(第一个循环找到第一个出现,第二个循环找到第二个出现的字符串),它与循环参数值相关联。
<exec executable="${postgres-bin-dir}/psql" outputproperty="update-primary-keys-values-@table">
<arg line="-A -t --host ${source-target-comparison-hostname} --port 5432 --username 'postgres' -d ${source-target-comparison-databasename} -c "array_to_string(ARRAY(select ${primary-keys-@{table}} from stage.@{table} t where t not in (select t from public.@{table} t) and t.${primary-keys-@{table}} not in (select ${primary-keys-@{table}} from stage.@{table} where ${primary-keys-@{table}} not in (select ${primary-keys-@{table}} from public.@{table})) order by ${primary-keys-@{table}}), ',')""/>
</exec>
<for list="${update-primary-keys-values-@table}" param="keys-values">
<replace file="${updates-dir}/updates@{table}.sql" token=");" value=") WHERE ${primary-keys-@{table}} = @{keys-values};"/>
</for>