You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Matt Reason <ma...@movielink.com> on 2004/03/04 23:23:41 UTC

echo "something" >> somefile

 
I am trying get ant to do the exact equivalent of:
echo "This is a line of text in a file" >> file.txt 
Note that I am appending to the file.
 
I want a text file in my build directory that has two columns:
Build_Number and Build_Date.  Each time I do a build, I want to add one
line to that file.
 
Ant keeps putting the output on the same line.  A solution is to put a
carriage return in the message itself, but that destroys my formatting -
something that I am obsessive about.   If I put the </echo> in the right
(formatted) spot, then I get all the tabs in my output file  (see below)
.
 
Is there a way to append a single line at the end of a file?  Or do I
need to call exec?   Why would echo in ant have been designed
differently than echo in all other languages?
 
Thanks in advance,
 
Matt
 
<!-- This keeps appending to the same line. -->
<target name="logit">
  <echo file="log" append="true">${buildNum} ${BuildDate}.</echo>
</target>
 
<!-- This works but makes my skin crawl. (and will be formated by my
IDE)-->
<target name="logit">
  <echo file="log" append="true">${buildNum} ${BuildDate}.
</echo>
</target>
 
<!-- This indents each line by two spaces. -->
<target name="logit">
  <echo file="log" append="true">${buildNum} ${BuildDate}.
  </echo>
</target>
 

Re: echo "something" >> somefile

Posted by Robert Clark <Ro...@quest.com>.
On Thu, 2004-03-04 at 17:23, Matt Reason wrote:
> Is there a way to append a single line at the end of a file?  Or do I
> need to call exec?   Why would echo in ant have been designed
> differently than echo in all other languages?
>  
> Thanks in advance,
>  
> Matt
>  
> <!-- This keeps appending to the same line. -->
> <target name="logit">
>   <echo file="log" append="true">${buildNum} ${BuildDate}.</echo>
> </target>

Try:

<echo file="log" append="true">
${buildNum} ${BuildDate}.</echo>

To append a new line and then the text or the other way around:

<echo file="log" append="true">${buildNum} ${BuildDate}.
</echo>

to append the text and then a new line.

- Rob



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: echo "something" >> somefile

Posted by Matt Benson <gu...@yahoo.com>.
--- Matt Reason <ma...@movielink.com> wrote:
>  
> I am trying get ant to do the exact equivalent of:
> echo "This is a line of text in a file" >> file.txt 
> Note that I am appending to the file.

What about
<echo file="log" append="true"
message="${buildNum}${line.separator}${BuildDate}" />

?

-Matt


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org