how can i filter whole line which contains a specific string
i have the following Ant script for reading re开发者_C百科visionlog.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.
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
精彩评论