2016年1月29日星期五

Mac中运行shell脚本command not found问题

写了一个a.sh文件:
#!/bin/bash
echo "hello"

通过 bash a.sh 或者 sh a.sh 执行都没有问题。

但 sudo ./a.sh 执行的时候报下面的错:
sudo: ./a.sh: command not found

解决方法,给该文件添加执行权限:
sudo chmod a+x a.sh
完成。

没有评论:

发表评论