How to test if package is installed? [duplicate]
Solution 1:
You could use the output of
dpkg -s <packagename>
or dpkg-query -l <packagename>
in your script for the purpose.
Courtesy:https://stackoverflow.com/questions/1298066/check-if-a-package-is-installed-and-then-install-it-if-its-not
e.g.
#!/bin/sh
for P; do
dpkg -s "$P" >/dev/null 2>&1 && {
echo "$P is installed."
} || {
echo "$P is not installed."
}
done
Usage: script.sh package1 package2 .... packageN
Courtesy:https://stackoverflow.com/a/10594734/749232