Reputation: 281
How within Apache Ant can I filter OUT only lines that don't begin with INSERT like I believe is possible (see below) with grep.
cat specialtable.inserts.sql | grep INSERT > specialtable.inserts.ONLY.sql
Upvotes: 1
Views: 475
Reputation: 66783
You can use the linecontains or linecontainsregexp filter readers
<copy file="specialtable.inserts.sql" tofile="specialtable.inserts.ONLY.sql">
<filterchain>
<linecontains>
<contains value="INSERT"/>
</linecontains>
</filterchain>
</copy>
If you wanted to filter the file to include all lines that contain INSERT, UPDATE, or DELETE then use linecontainsregexp
:
<copy file="specialtable.inserts.sql" tofile="specialtable.inserts.ONLY.sql">
<filterchain>
<linecontainsregexp>
<regexp pattern="INSERT|UPDATE|DELETE"/>
</linecontainsregexp>
</filterchain>
</copy>
You could also use the casesensitive
attribute and a more complex REGEX expression to ensure that the lines start with those words.
Upvotes: 1