ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant Reddy <prash...@pramati.com>
Subject Re: How to get the count of the number of lines in a file using ANT
Date Wed, 10 Oct 2007 04:42:40 GMT
On Tue, 2007-10-09 at 12:25 -0700, Saladin Sharif wrote:
> But what I am really after is being able to set a flag if the file
> contains one or more lines of text.

oh you are looking to do something like :  
cat log.txt | grep "a string" | wc -l 

<loadfile srcfile="${output}" property="contains.errors">
        <filterchain>
               <linecontains>
                   <contains value="${lookingFor}"/>
            </linecontains>
       </filterchain>
 </loadfile>
 <echo file="${basedir}/temp.txt" message="${contains.errors}"/>

So now you have the lines from the ${output} which contain ${lookingFor}
in a temp file temp.txt

After this, you could use the example Matt gave to find out the number
of lines in temp.txt

Hope this helps.
-- 

-Prashant

Don't upload, just share : www.dekoh.com


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


Mime
View raw message