Created
April 22, 2014 06:48
-
-
Save joseluisq/11167686 to your computer and use it in GitHub Desktop.
How to check if some package is installed on linux system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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