How to replace all lines of a file with their substring with Ant?
Question
E.g. to trim the first n characters of the lines, so that
123
1234
becomes
3
34
?
Solution
<target name="test">
<property name="trim_count" value="2"/>
<copy file="c:/test.txt" tofile="c:/test2.txt" overwrite="true">
<filterchain>
<tokenfilter>
<linetokenizer/>
<replaceregex pattern="^.{1,${trim_count}}(.*)" replace="\1"/>
</tokenfilter>
<ignoreblank/>
</filterchain>
</copy>
</target>
OTHER TIPS
I think you need to write a java class to accomplish that.
I don't think Ant supports this type of functionality by default. Instead you'd have to use an external utility. If you share some specifics of the OS you are using, as well as what kind of characters or pattern that you are attempting to remove we might be able to further aid you.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow