Created
September 4, 2019 08:15
-
-
Save Ji-Yuhang/e1c7a71a9c698233b65887a71fa0088c to your computer and use it in GitHub Desktop.
对 dist文件下所有对文件按大小进行排序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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