shell小技巧(二十四)检查软件是否安装

代码:

#!/bin/bash
if [ -z $1 ]; then
   echo "neec software name"
   read -p "please software name:" softname
else
   softname=$1
fi
if  [ $(whereis $softname) == $softname":" ]; then
    echo "$softname is not installed"
else
    echo "sysstat is  installed"
fi  
总结:

本例使用whereis来判断软件是否安装。

网上有使用rpm来判断的,但是如果是编译安装,那么会检测不到。

发布了53 篇原创文章 · 获赞 3 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/bigwood99/article/details/105163508