Shell检查安装rpm包 发表于 2017-04-10 | 分类于 Shell Shell检查安装rpm包 Shell检查安装rpm包脚本 1234567891011121314151617181920212223242526272829[root@hzvscmdb check]# vim check_rpm3.sh###################RPM_CHECK##################!/bin/bash#filename: check_rpmuname -rrpm --versionP=${1?" must specify package name."}check_rpm(){ while (( $# > 0 )) do if ! rpm -q $1 &> /dev/null;then yum install $1 -y &>/dev/null if [ $? == 0 ];then echo "$1 install is success!" else echo "$1 is not in the systerm Packages!" fi else echo "$1 is installed" fi shift done exit 0}check_rpm $@ 运行以下命令查看安装的包 1234567891011121314151617181920212223[root@hzvscmdb check]# ./check_rpm3.sh binutils elfutils-libelf glibc glibc-common libaio libgcc libstdc++ make compat-libstdc++-33 elfutils-libelf-devel glibc-headers glibc-devel libgomp gcc gcc-c++ libaio-devel libstdc++-devel unixODBC unixODBC-devel sysstat2.6.32-279.el6.x86_64RPM version 4.8.0binutils is installedelfutils-libelf is installedglibc is installedglibc-common is installedlibaio is installedlibgcc is installedlibstdc++ is installedmake is installedcompat-libstdc++-33 is installedelfutils-libelf-devel is installedglibc-headers is installedglibc-devel is installedlibgomp is installedgcc is installedgcc-c++ is installedlibaio-devel is installedlibstdc++-devel is installedunixODBC is installedunixODBC-devel is installedsysstat is installed