Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find replace text in file with Phing

Tags:

phing

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

like image 886
milan Avatar asked Feb 05 '11 14:02

milan


People also ask

How do I replace a text file in Linux?

Find and replace text within a file using sed command Use Stream EDitor (sed) as follows: sed -i 's/old-text/new-text/g' input.txt. The s is the substitute command of sed for find and replace. It tells sed to find all occurrences of 'old-text' and replace with 'new-text' in a file named input.txt.


1 Answers

If you don't want to copy files and just replace a string in the current folder where your files reside, do a reflexive task:

<reflexive>
    <fileset dir=".">
        <include pattern="*.js" />
    </fileset>
    <filterchain>
        <replaceregexp>
            <regexp pattern="SEARCH" replace="REPLACEMENT"/>
        </replaceregexp>
    </filterchain>
</reflexive>
like image 150
acme Avatar answered Oct 26 '22 02:10

acme