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这样的全路径

3年前 评论
讨论数量: 2

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

3年前 评论

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

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!