Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Created April 22, 2014 06:48
Show Gist options
  • Save joseluisq/11167686 to your computer and use it in GitHub Desktop.
Save joseluisq/11167686 to your computer and use it in GitHub Desktop.
How to check if some package is installed on linux system
#!/bin/sh
# This test uses the `type` command to check if package is installed.
# Tested on Fedora Linux x64
# Miscellaneous
B=`tput bold`
N=`tput sgr0`
# Package name
PACKAGENAME="git"
# Searching for package on system
FILEPATH="`type -P ${PACKAGENAME}`"
# Checking for package
if [ -z $FILEPATH ];
then
echo "The ${B}${PACKAGENAME}${N} package is not installed on your system."
else
echo "The ${B}${PACKAGENAME}${N} package is already installed at ${B}${FILEPATH}${N}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment