2013-03-02 23:00:38 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
_printhelp()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: ${1##*/} [OPTIONS] PACKAGES
|
|
|
|
|
|
|
|
Display size of files in PACKAGES.
|
|
|
|
|
|
|
|
-h: Display this help.
|
|
|
|
-n: Sort by size.
|
2013-10-23 11:24:32 +02:00
|
|
|
|
2013-03-02 23:00:38 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
OPTION_SORT="cat"
|
|
|
|
|
|
|
|
while getopts ":hn" opt; do
|
|
|
|
case $opt in
|
|
|
|
h)
|
|
|
|
_printhelp "$0"
|
2013-10-23 11:24:32 +02:00
|
|
|
exit 1 ;;
|
2013-03-02 23:00:38 +01:00
|
|
|
n)
|
2013-10-23 11:24:32 +02:00
|
|
|
OPTION_SORT="sort -h" ;;
|
2013-03-02 23:00:38 +01:00
|
|
|
?)
|
|
|
|
_printhelp "$0"
|
2013-10-23 11:24:32 +02:00
|
|
|
exit 1 ;;
|
2013-03-02 23:00:38 +01:00
|
|
|
:)
|
|
|
|
echo "Missing argument."
|
|
|
|
_printhelp "$0"
|
2013-10-23 11:24:32 +02:00
|
|
|
exit 1 ;;
|
2013-03-02 23:00:38 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "Missing argument."
|
|
|
|
_printhelp "$0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-10-23 11:24:32 +02:00
|
|
|
[ -z "$(command -v pacman)" ] && echo "You need pacman to run this script." && exit 1
|
|
|
|
|
2013-03-02 23:00:38 +01:00
|
|
|
du -bch $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u) 2>/dev/null | eval ${OPTION_SORT}
|