Skip to content

Instantly share code, notes, and snippets.

@awesome
Created January 14, 2020 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awesome/72d007979e2b2639d32a508fc76a66c2 to your computer and use it in GitHub Desktop.
Save awesome/72d007979e2b2639d32a508fc76a66c2 to your computer and use it in GitHub Desktop.
"Dpkg: check that unix package is installed. Bash script: install package if not present" via https://www.thinkplexx.com/learn/howto/linux/packaging/dpkg-check-that-unix-package-is-installed-example-install-package-if-not-present
Dpkg: check that unix package is installed. Bash script: install package if not present
By neokrates, written on May 21, 2010
Was the package already installed or it still needs to be?
Software:
✔ Ubuntu *
dpkg -s can be used.
# Example: is libasound installed?
dpkg -s libasound2|grep installed
# Here is some logic in bash script, like installing package if it is not there:
problem=$(dpkg -s xulrunner-1.9|grep installed)
echo Checking for libxul: $problem
if [ "" == "$problem" ]; then
echo "No libxul. Setting up libxul"
sudo apt-get --force-yes --yes install xulrunner-1.9
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment