How to write a nant open file and replace string script

Posted on 2008-10-13
Medium Priority
Last Modified: 2013-11-10
After attempting many different methods I would appreciate input.  Why does the following not work.  It does not appear to be touching the file at all.

<copy file="${makedir}\make.i" tofile="${makedir}\make.i.bak"/>                                                    
<loadfile file="${makedir}\make.i" " property="${makedir}\make.i.bak">
              <replacestring from="#old" to="new"/>
<copy file="${makedir}\make.i.bak"  tofile="${makedir}\make.i"/>
<loadfile file="${makedir}\make.i.bak" property="${makedir}\make.i">

Question by:roverplant

Expert Comment

ID: 22742724
Try sed instead:

sed 's/old/new/g' $mkdir/make.i >  $mkdir/make.i.bak && mv $mkdir/make.i.bak $mkdir/make.i

Accepted Solution

roverplant earned 0 total points
ID: 22836795
<move file="${makedir}\make.i" tofile="${makedir}\make.i.bak"/>      
copy file="${makedir}\make.i.bak" tofile="${makedir}\make.i">                                                    
              <replacestring from="#old" to="new"/>

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Screencast - Getting to Know the Pipeline

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question