0x1949 Team - FAZEMRX - MANAGER
Edit File: dpigs
#!/bin/sh # dpigs - Show which installed packages occupy the most space # Copyright (C) 2001,2002 Matt Zimmerman <mdz@debian.org> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # set -e # set locale for sorting LC_NUMERIC=C export LC_NUMERIC Usage() { echo "Usage: dpigs [options]" echo echo "Options:" echo " -n, --lines=N" echo " Display the N largest packages on the system (default 10)." echo " -s, --status=status-file" echo " Use status-file instead of the default dpkg status file." echo " -S, --source" echo " Display the largest source packages of binary packages installed" echo " on the system." echo " -H, --human-readable" echo " Display package sizes in human-readable format (like ls -lh or du -h)" echo " -h, --help" echo " Display this message." } LINES=10 # grep-status provides a default STATUS= # Default: provide binary package information SOURCE=0 # Default: display kilobytes HUMAN=0 OPTS=$(getopt -o n:s:ShH --long lines:,status:,source,help,human-readable -- "$@") eval set -- "$OPTS" while true; do case "$1" in -n|--lines) LINES="$2" shift 2 ;; -s|--status) STATUS="$2" shift 2 ;; -S|--source) SOURCE=1 shift 1 ;; -H|--human-readable) HUMAN=1 shift 1 ;; -h|--help) Usage exit 0 ;; --) shift break ;; *) Usage exit 1 ;; esac done if [ $SOURCE -eq 0 ] ; then grep-status -nsInstalled-size,Package -F Status ' installed' $STATUS \ | perl -p00l12 -e 's/\n/ /' \ | sort -rn \ | head --lines=$LINES else # Order by source package grep-status -nsInstalled-size,Source:Package -F Status ' installed' $STATUS \ | perl -n00a -e '$s{$F[1]}+=$F[0]; END { for(keys %s) {print"$s{$_} $_\n"} }' \ | sort -rn \ | head --lines=$LINES # Alternatively use this: # It adds details of which binary packages are # involved (but not how big they are), with % standing in for the source #grep-status -nsInstalled-size,Package,Source:Package -F Status ' installed' \ # $STATUS \ # | perl -n00al12 -e '$s{$F[2]} += $F[0]; # $F[1] =~ s/\Q$F[2]\E/%/; $b{$F[2]}{$F[1]} = 1; # END {$, = " "; for(keys %s) {print "$s{$_} $_:", sort keys %{$b{$_}}} }' \ # | sort -rn \ # | head --lines=$LINES fi | if [ $HUMAN -eq 1 ]; then awk '{ if ($1 > 1024*1024*1024) printf("% 6.1fT %s\n", $1/(1024*1024*1024), $2); else if ($1 > 1024*1024) printf("% 6.1fG %s\n", $1/(1024*1024), $2); else if ($1 > 1024) printf("% 6.1fM %s\n", $1/1024, $2); else printf("% 6.1ik %s\n", $1, $2); }' else cat fi