【原创】【Mac】创建可以双击执行Shell脚本文件(类似windows批处理脚本)

使用输出hello world!为例。

1、制作shell脚本,并赋予执行权限

cd ~/Desktop
touch test.sh
vim test.sh(输入 echo "hello world!" )
chmod 755 test.sh
./test.sh 

输出:hello world!

 

2、制作可双击执行的脚本

只需将后缀sh改成command

cp test.sh test.command

3、双击command脚本

输出:hello world!

 

------------------------------- ********厚德达理,励志勤工******** -------------------------------
原文地址:https://www.cnblogs.com/hightech/p/14456379.html