腳本示例
vim hello.sh
#!/bin/bash
>註釋:#! 是一個約定的標記,它告訴系統這個腳本需要什麼解釋器來執行,即使用哪一種 Shell
echo "Hello World !"
運行腳本的兩種方法
作爲可執行文件
chmod +x ./hello.sh ./hello.sh
使用解釋器
/bin/bash hello.sh
vim hello.sh
#!/bin/bash
>註釋:#! 是一個約定的標記,它告訴系統這個腳本需要什麼解釋器來執行,即使用哪一種 Shell
echo "Hello World !"
作爲可執行文件
chmod +x ./hello.sh
./hello.sh
使用解釋器
/bin/bash hello.sh