Skip to content

Instantly share code, notes, and snippets.

@charlieparkes
Created May 31, 2018 01:34
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 charlieparkes/16e61e5fd2fc92f2110017b4db2d94dd to your computer and use it in GitHub Desktop.
Save charlieparkes/16e61e5fd2fc92f2110017b4db2d94dd to your computer and use it in GitHub Desktop.
Debian packages by size #bash
#!/bin/sh
# lists installed Debian packages, sorting by package size
# This could just be a perl script extracting the install package info.
# but I made it a sh script to allow for sort manipulation afterwards.
# Installed packages read from /var/lib/dpkg/status
echo '
open(FILE,"/var/lib/dpkg/status");
$_=<FILE>;
while ($_)
{
if ( /Package:/ )
{
@package = split(" ",$_);
$_=<FILE>;
if ( /install ok installed/ )
{
do
{
$_=<FILE>;
}
until ( /Size:/ );
@size = split(" ",$_);
print( "$package[1] $size[1]\n");
}
}
$_=<FILE>;
}
' | perl | sort -nr -k2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment