find replace text in file with Phing

后端 未结 6 1121
误落风尘
误落风尘 2021-02-04 06:10

Does anyone know how to find and replace text inside a file with Phing?

6条回答
  •  长发绾君心
    2021-02-04 06:21

    The simplest way to achieve this using 'traditional' tools would be sed:

    sed -i 's/old/new/g'  myfile.txt
    

    And if it is ant-based then this should help: http://ant.apache.org/manual/Tasks/replace.html

    The simplest form would be .

    And if you really need it, you could run external tools with ant as documented at http://ant.apache.org/manual/Tasks/exec.html, which means that among other things you could, for example, call sed from ant with something like:

     
       
       
     
    

提交回复
热议问题