Skip to content

Instantly share code, notes, and snippets.

@volh
Created October 19, 2010 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volh/635428 to your computer and use it in GitHub Desktop.
Save volh/635428 to your computer and use it in GitHub Desktop.
# Sort packages by their sizes, descending
`pacman -Qi`.split("\n\n").map do |pkg|
pkg.split("\n")
end
.sort_by do |pkg|
pkg.grep(/Size/).first.split(":").last.to_f
end
.reverse[0 .. ARGV.first.to_i - 1].map do |i|
name = i.first.split(":").last.strip
size = i.grep(/Size/).first.split(":").last.to_f / 1024
puts name << (" " * (25 - name.size)) << "\t --> \t" << "%.2f" % size
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment