Solved

How to write a nant open file and replace string script

Posted on 2008-10-13
3
4,613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is about my first experience with programming Arduino.
Simple Linear Regression
Introduction to Processes

635 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