ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: How do you sort and remove duplicates lines from a file ?
Date Wed, 02 Jul 2008 08:00:57 GMT

-----Original Message-----
From: Paul Taylor [] 
Sent: Tuesday, July 01, 2008 11:48 PM
To: Matt Benson
Cc: Ant Users List
Subject: Re: How do you sort and remove duplicates lines from a file ?

With the example of Matt it's getting clearer, but
like Scot i never used the <concat> task, like Paul i feel it's
not very intuitive to use.

Personally i would prefer a little <script>, but that's a matter of

reading, sorting and writing to another file =

<script language="ruby">
<![CDATA["sorted.txt", "w") do |file|
    File.readlines("sort.txt").uniq.sort.each do |line|

echoing, setting a property =

<script language="ruby">
  linesarr = File.readlines("sort.txt").uniq.sort.collect {|line|
  puts "Sorted Lines => " + linesarr.to_s
  $project.setProperty "sortedfile", linesarr.to_s

(chomp and afterwards appending \n again for the case
when there's no linefeed after last line, that would result in
two lines on one after sorting)

Regards, Gilbert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message