緒論
有關Shell腳本的一篇文章。
正文
- shell腳本實際上就是一系列命令的集合。
- shell腳本開頭需要加上 #!/bin/bash 或 #!/bin/sh。
- #! 是一個約定的標記,它告訴系統這個腳本需要什麼解釋器來執行,即使用哪一種 Shell。
- 以#開頭的行視爲註釋。
- 腳本的名字以.sh結尾。
- 查看腳本執行過程:bash -x test.sh。
- 查看腳本是否語法錯誤:bash -n test.sh。
- chmod +x ./test.sh #使腳本具有執行權限。
- 執行方式:1)bash test.sh。2)./test.sh。
- bash可以使用sh命令代替(在/usr/bin目錄下,sh是bash的軟連接文件)。
結果
無
(若有什麼錯誤,請留言指正,3Q)