Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash check if package is installed

REQUIRED_PKG="some-package"
PKG_OK=$(dpkg-query -W --showformat='${Status}
' $REQUIRED_PKG|grep "install ok installed")
echo Checking for $REQUIRED_PKG: $PKG_OK
if [ "" = "$PKG_OK" ]; then
  echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
  sudo apt-get --yes install $REQUIRED_PKG 
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #check #package #installed
ADD COMMENT
Topic
Name
8+1 =