ubuntu18.04运行脚本报错let: not found

gcc@gcc-x64:/mnt$ ./cpu_usage.sh
./cpu_usage.sh: 15: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 16: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 17: ./cpu_usage.sh: let: not found
CPU: %
./cpu_usage.sh: 15: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 16: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 17: ./cpu_usage.sh: let: not found
CPU: %
./cpu_usage.sh: 15: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 16: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 17: ./cpu_usage.sh: let: not found
CPU: %
./cpu_usage.sh: 15: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 16: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 17: ./cpu_usage.sh: let: not found
CPU: %
./cpu_usage.sh: 15: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 16: ./cpu_usage.sh: let: not found
./cpu_usage.sh: 17: ./cpu_usage.sh: let: not found
CPU: %
^C
gcc@gcc-x64:/mnt$ let
-bash: let: expression expected
gcc@gcc-x64:/mnt$ sudo let
[sudo] password for gcc:
sudo: let: command not found

原因是/bin/sh 指向了 dash 而不是 bash ,但是 dash 不支持 let 命令。

解决办法,直接使用bash运行脚本即可。

bash 空格 脚本,回车即可

此条目发表在Linux, Tips分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注