File: dpigs

package info (click to toggle)
debian-goodies 0.27+etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 160 kB
  • ctags: 61
  • sloc: sh: 518; python: 370; makefile: 43
file content (56 lines) | stat: -rwxr-xr-x 1,093 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

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 "  -h, --help"
    echo "    Display this message."
}

LINES=10
# grep-status provides a default
STATUS=

OPTS=$(getopt -o n:s:h --long lines:,status:,help -- "$@")
eval set -- "$OPTS"

while true; do
    case "$1" in
        -n|--lines)
            LINES="$2"
            shift 2
            ;;
        -s|--status)
            STATUS="$2"
            shift 2
            ;;
        -h|--help)
            Usage
            exit 0
            ;;
        --)
            shift
            break
            ;;
        *)
            Usage
            exit 1
            ;;
    esac
done

grep-status -nsInstalled-size,Package -F Status ' installed' $STATUS \
| perl -p00l12 -e 's/\n/ /' \
| sort -rn \
| head --lines=$LINES