1. if...then...else结构(条件语句)
if [ expr ]
then
;
elif [ expr ]
then
else
;
fi
中括号表示一个 test 命令,中括号和测试条件"expr"之间需要有空格;
test命令有不同的测试,如文件、字符串比较、数字比较;
expr和expr可以通过,-o(or) -a(and) !(expr)(取反)来做逻辑运算;
else语句是可选的;
if和then在同一行需要有分号隔离,if [ expr ];then
2. for结构
for val in words-list
do
...
done