【发布时间】:2015-01-07 08:42:05
【问题描述】:
我意识到这可能是一个愚蠢的问题,但我安装了 Centos-7 最小服务器,并且“which”命令不存在或丢失。 我有一个需要它的脚本,但我找不到安装它的 yum 包。 代码如下,来自一个 make 文件。
which grep > /dev/null 2> /dev/null
if test "$?" != "0"
then
echo "\"grep\" command not found."
echo "Installation is aborted."
exit 1
fi
任何帮助都将不胜感激......这对于谷歌来说即使不是不可能也很困难
【问题讨论】:
-
缺少
grep或which吗? -
顺便说一句,您的代码有几个错误。你想要的只是
if ! type -p grep >/dev/null 2>&1; then echo "grep not found, installation aborted" >&2; fi -
非常不笨;我的 centos7 体验中缺少
make和which让我有点惊讶,所以谢谢你的提问。 @Wintermute 的回答对我很有教育意义。
标签: bash shell command centos7 yum