shell 脚本中使用 whereis 命令

环境:Ubuntu

在脚本中使用如下命令报错

BIN='php redis'

for bin in $BIN
do
    echo `whereis $bin`
    #或者这样
    echo $(whereis $bin)
    echo $(whereis ${bin})
done

得到的报错信息都是这样

line 21: whereis: command not found

这是个啥问题,如果解决啊

城里的野山参
最佳答案

应该是路径找不到,SHELL 脚本要么开头声明环境变量,要么就得用 /usr/sbin/whereis 这样的全路径

4年前 评论
讨论数量: 2

应该是路径找不到,SHELL 脚本要么开头声明环境变量,要么就得用 /usr/sbin/whereis 这样的全路径

4年前 评论

whereis 不在当前 shell 的 PATH 变量中。

4年前 评论