本文參考自 《Linux Shell命令行及腳本編程實例詳解 》
Shell 腳本的組成部分:
1.Shell 關鍵字 —— 例如 if...else,for do...done
2.Shell 命令 —— 例如 export,echo,exit,pwd,return
3.Linux 命令 —— 例如 date,rm,mkdir
4.文本處理功能 —— 例如 awk,cut,sed,grep
5.函數 —— 通過函數把一些常用的功能放在一起。例如,/etc/init.d 目錄中的大部分或全部系統 Shell 腳本所使用的函數都包含在文件 /etc/init.d/functions 中。
6.控制流語句 —— 例如 if...then...else 或執行重復操作的 Shell 循環。