美文网首页思科DevNet
Mac OS 终端运行.sh脚本

Mac OS 终端运行.sh脚本

作者: LeLeBa | 来源:发表于2016-12-14 16:20 被阅读2651次

1、编辑脚本文件。例如 test.sh 保存到 /Users/电脑用户名/Documents 目录下。内容:

!/bin/bash

echo "hello";

2、打开终端,运行 cd /Users/电脑用户名/Documents 进入目录;

3、直接运行 test.sh;

如果提示 -bash: test.sh: command not found 错误,设置 PATH :

export PATH=$PATH:/Users/电脑用户名/Documents

有时候也会提示 -bash: test.sh: No such file or directory,同样运行签名的命令,设置PATH即可解决;

再次运行,在控制台就能看到 hello 了!

如果还不行,试试 chmod u+x test.sh 提升文件权限后,再运行脚本。

相关文章

网友评论

    本文标题:Mac OS 终端运行.sh脚本

    本文链接:https://www.haomeiwen.com/subject/ysgimttx.html