sh文件运行:

1、修改为可执行权限:

chmod u+x hello.sh

2、运行

./hello.sh

3、不使用可执行权限修改,用sh直接运行

sh ./hello.sh

桌面环境双击运行sh文件:

Mac:

1、修改后缀sh变成command:hello.sh->hello.command

2、修改可执行权限:chmod u+x hello.command

Ubuntu:

1、修改可执行权限:chmod u+x hello.sh

2、任意打开一个文件夹,选择左上角的【编辑】->【首选项】

选择【打开可执行文本文件时运行它们】即可实现双击运行。

 

参考:

http://blog.csdn.net/lipeiran1987/article/details/18406535

http://www.cnblogs.com/jackchiang/p/4676984.html

版权声明:本文为EasonJim原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/EasonJim/p/7467457.html