This file is indexed.

/usr/bin/dpigs is in debian-goodies 0.63.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/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