Skip to content

Instantly share code, notes, and snippets.

@dentedtriangle
Created June 25, 2012 10:14
Show Gist options
  • Save dentedtriangle/2987784 to your computer and use it in GitHub Desktop.
Save dentedtriangle/2987784 to your computer and use it in GitHub Desktop.
list files in directory
require 'find'
files = {}
Find.find('.') do |f|
if(f != '.' && f != '..' && File.file?(f) && !f.include?('git'))
size = File.size(f)
if(size > 0)
files[f] = size
end
end
end
sorted = files.sort_by {|k,v| v}.reverse
i = 0
sorted.each do |k,v|
break if i == 20
puts "File: #{k} - Size: #{v}"
i = i + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment