Solved

How to write a nant open file and replace string script

Posted on 2008-10-13
3
4,488 Views
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">
      <filterchain>
              <replacestring from="#old" to="new"/>
                     </filterchain>
<copy file="${makedir}\make.i.bak"  tofile="${makedir}\make.i"/>
<loadfile file="${makedir}\make.i.bak" property="${makedir}\make.i">
    </loadfile>

0
Comment
Question by:roverplant
3 Comments
 
LVL 2

Expert Comment

by:tdiops
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
0
 

Accepted Solution

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now