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、任意打開一個文件夾,選擇左上角的【編輯】->【首選項】
選擇【打開可執行文本文件時運行它們】即可實現雙擊運行。
參考: