我想在一行中使用rpm命令检查是否安装了特定的Linux包。然而,作为服务存在,它总是给我一个积极的结果,即使没有安装httpd,您能在这里指出问题吗?
rpm
httpd
rpm -qa httpd && echo "service present" || echo " service not present"
dwbf0jvd1#
使用以下代码替换<PACKAGE_NAME>
<PACKAGE_NAME>
rpm -q <PACKAGE_NAME> && echo "service present" || echo "service not present"
rpm -qa <PACKAGE_NAME> | grep <PACKAGE_NAME> && echo "service present" || echo "service not present"
示例:
rpm -qa httpd | grep httpd && echo "service present" || echo "service not present"
# Output [root@bfa3155b8feb /]# rpm -qa httpd | grep httpd && echo "service present" || echo "service not present" service not present
1条答案
按热度按时间dwbf0jvd1#
使用以下代码替换
<PACKAGE_NAME>
更短
rpm -q <PACKAGE_NAME> && echo "service present" || echo "service not present"
加长
rpm -qa <PACKAGE_NAME> | grep <PACKAGE_NAME> && echo "service present" || echo "service not present"
示例: