From: Derek Smith Date: 2009-10-31T10:38:04+09:00 Subject: mtime.max Hi All, My goal is to get the oldest file using mtime.to_i then delete it. However my puts stats.to_a.max does not seem to print out the oldest mtime data/file, rather its printing out the 2nd to oldest file; prod_db_bkup_Tue2009-10-271455.gz Correct me please and show me the code. thx! d=Date.today t=Time.now require 'enumerator' stats = Hash.new DB_BKUP1.each do |dbfile| stats[dbfile] = [File.stat(dbfile).mtime.to_i] end puts stats.to_a,"\n\n" puts stats.to_a.max end prod_DB_OS_bkup.rb: 90 lines, 2627 characters. [root@vixxxxx /usr/local/vrep/OS_scripts]# ruby prod_DB_OS_bkup.rb /usr/local/vrep/prod_db_bkup_Thr2009-10-29110.gz 1256828444 /usr/local/vrep/prod_db_bkup_Thr2009-10-291054.gz 1256828056 /usr/local/vrep/prod_db_bkup_Fri2009-10-301042.gz 1256913745 /usr/local/vrep/prod_db_bkup_Thr2009-10-291052.gz 1256827961 /usr/local/vrep/prod_db_bkup_Tue2009-10-271455.gz 1256669730 /usr/local/vrep/prod_db_bkup_Tue2009-10-271642.gz 1256676168 /usr/local/vrep/prod_db_bkup_Tue2009-10-271642.gz 1256676168 -- Posted via http://www.ruby-forum.com/.