Created
May 31, 2018 01:34
-
-
Save charlieparkes/16e61e5fd2fc92f2110017b4db2d94dd to your computer and use it in GitHub Desktop.
Debian packages by size #bash
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
#!/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