Sort and List Installed Ubuntu/Debian Packages by size

If you’re like me, you’ll try every package in the Ubuntu Repository. I just love to try different applications. But then I end up having zillions of applications on my laptop and hardly any disk place. Thats when I start pruning. But for that I need to know what to prune. Thats what the following script does. It lists and sorts all the installed deb packages according to size.

perl -ne '$pkg=$1 if m/^Package: (.*)/; print "$1\t$pkg\n" if m/^Installed-Size: (.*)/;' < /var/lib/dpkg/status | sort -rn | less