Determinate if debian package is installed or not
Fr, 07/30/2010 - 12:27 | by Reox
if [ "$(dpkg -s locales 2>/dev/null | grep Status | awk -F' ' '{ print $4 }')" != "installed" ]
then
apt-get install locales -yy
fi
i think thats the best way, or is there a better?
Kommentare
Warum tut's ein einfaches
Warum tut's ein einfaches "apt-get install locales" nicht?
Wenn locales schon installiert war, tut der apt-get ja eh nix...
Wenn's wirklich auf die Entscheidung ankommt, würd ich nach ^Status greppen, sonst könnte (zumindest bei anderen packages als locales) ein "Status"-Vorkommen in der Paket-beschreibung das Ergebnis stören.
nachsatz...
Und der grep lässt sich natürlich vom awk mit-erledigen:
awk -F' ' '/^Status/ {print $4}'