X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=scripts%2Flist-dates.rb;h=18cdef98418ccae7b6cd6bf4fcef24a2de738924;hb=cbfcd06cb32cc5c35bfb8ddb499cb952024068a4;hp=b8a5c5099efc057853c162dc0fe61a032e14190d;hpb=e1e129263bcf5a1ab54def78084240653ef070b9;p=backups%2F.git diff --git a/scripts/list-dates.rb b/scripts/list-dates.rb index b8a5c50..18cdef9 100755 --- a/scripts/list-dates.rb +++ b/scripts/list-dates.rb @@ -1,14 +1,17 @@ #!/usr/bin/ruby +# Make sure the record separator is zero rather than new-line +$/ = "\0" + +# Create a set of backup dates require 'set' +dates = SortedSet.new -dates = Set.new +# Split each input record into 8 fields on spaces and grab the 7th as integer +date_array = ARGF.map { |rec| rec.split( ' ', 8 )[6].to_i } -ARGF.each( "\0" ) do |line| - fields = line.split ' ', 8 - dates.add fields[6] -end +# Merge the dates into the set +dates.merge date_array -dates.each do |date| - puts date -end +# Output the sorted set +puts dates.to_a