Reputation: 5315
i have the following Ant script for reading revisionlog.txt file line by line and printing all the line.
<target name="line_by_line">
<loadfile property="file" srcfile="revisionlog.txt"/>
<for param="line" list="${file}" delimiter="${line.separator}">
<sequential>
<echo>@{line}</echo>
</sequential>
</for>
</target>
but here i want to print those line only which contains Comments:
string.
how can i do this.
Upvotes: 1
Views: 4625
Reputation: 10377
you may use loadfile
combined with a filterchain, f.e. :
<loadfile property="yourline" srcfile="revisionlog.txt">
<filterchain>
<linecontains>
<contains value="Comments:"></contains>
</linecontains>
</filterchain>
</loadfile>
<echo>$${yourline} = ${line.separator}${yourline}</echo>
if you need more control, use <linecontainsregexp>
see Ant manual for FilterChains and FilterReaders
Upvotes: 3