要控制程序檔的流程,外圍程序需包含 while、if、for 及 case 建構元。
If 用於檢查運算式。例如,以下程式碼將測試目前的使用者是否為 Tux︰
if test $USER = "tux" then echo "Hello Tux." else echo "You are not Tux." fi
測試運算式可以很複雜,也可以很簡單。下面的運算式會檢查檔案 foo.txt 是否存在︰
if test -e /tmp/foo.txt then echo "Found foo.txt" fi
http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/ch03sec02.html 中提供了更多運算式。