vendredi 14 mars 2008

Mon script sizeofdeb

J'ai écrit un (petit) script qui vous donne l'espace occupé par le package Debian donné en paramètre.

Voici le script:
#!/bin/bash
#
# sizeofdeb.sh - version 0.0.2
# Pierre Bauduin (pierre@baudu.in)
# le 14 mars 2008
#
# This script finds out how much space in kB is taken by the package given as a parameter
#

# Let's print some information
printf "$0 - finds out how much space in kB is taken by a Debian package\n"

# With how many parameters were we called ?
if [ "$#" != 1 ]; then
printf "Usage: $0 \n"
exit 1
else
# Here is the package we are looking for
NAME_OF_THE_DEBIAN_PACKAGE=$1
RESULT_OF_GREP_STATUS=`grep-status -nsInstalled-size,Package -F Status ' installed' $STATUS \
| perl -p00l12 -e 's/\n/ /' \
| grep -i $NAME_OF_THE_DEBIAN_PACKAGE`
# Is the string empty ?
if [ "$RESULT_OF_GREP_STATUS" = "" ]; then
# The string is empty
printf "Could not find any package matching $NAME_OF_THE_DEBIAN_PACKAGE. This means it is not installed or you made a typo.\n"
else
# The string is not empty
printf "$RESULT_OF_GREP_STATUS\n"
fi
fi


Exemples d'utilisation:

[pbn@cobra] /home/pibe>sizeofdeb finger
sizeofdeb - finds out how much space in kB is taken by a Debian package
76 finger

[pbn@cobra] /home/pibe>sizeofdeb iceweasel
sizeofdeb - finds out how much space in kB is taken by a Debian package
836 iceweasel-l10n-fr
24408 iceweasel
780 iceweasel-l10n-nl

[pbn@cobra] /home/pibe>sizeofdeb toto
sizeofdeb - finds out how much space in kB is taken by a Debian package
Could not find any package matching toto. This means it is not installed or you made a typo.

[pbn@cobra] /home/pibe>sizeofdeb evolution
sizeofdeb - finds out how much space in kB is taken by a Debian package
7660 evolution-data-server-common
1088 evolution-data-server
462 evolution-webcal
2672 evolution-exchange
384 evolution-plugins
7748 evolution
73582 evolution-common

Cliquez ici pour télécharger ce script (faites clic-droit-> Enregistrer sous)

Aucun commentaire: