Skip to content

Instantly share code, notes, and snippets.

@mdekstrand
Created June 22, 2011 17:53
Show Gist options
  • Save mdekstrand/1040676 to your computer and use it in GitHub Desktop.
Save mdekstrand/1040676 to your computer and use it in GitHub Desktop.
Perl script to print RPM packages by size
#!/usr/bin/env perl
use warnings;
use strict;
# get these with `yum install perl-RPM2 perl-Number-Bytes-Human'
use RPM2;
use Number::Bytes::Human qw{format_bytes};
my $db = RPM2->open_rpm_db();
my $i = $db->find_all_iter();
while (my $pkg = $i->next) {
my $sz = format_bytes($pkg->size);
my $n = $pkg->as_nvre;
my $arch = $pkg->arch;
$arch = 'noarch' unless defined $arch;
print "$sz\t$n.$arch\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment