Skip to content

Instantly share code, notes, and snippets.

@Ji-Yuhang
Created September 4, 2019 08:15
Show Gist options
  • Save Ji-Yuhang/e1c7a71a9c698233b65887a71fa0088c to your computer and use it in GitHub Desktop.
Save Ji-Yuhang/e1c7a71a9c698233b65887a71fa0088c to your computer and use it in GitHub Desktop.
对 dist文件下所有对文件按大小进行排序
#!/usr/bin/env ruby
data = Dir.glob("dist/**/*").map { |f| { file: f, size: File.size(f) } }.sort { |a, b| b[:size] <=> a[:size] }.each { |t| puts "size: #{t[:size]} , file: #{t[:file]}" }
total_size = data.reduce(0) { |s, f| f[:size] + s }
puts "Total size: #{total_size}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment