How to check if some package is installed on linux system via shell
#!/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
Written by Jose Luis Quintana
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#