Shell编程<1>---控制语句

时间:2014-12-08 21:25:16   收藏:0   阅读:225

最近在看 Linux 程序设计,准备写成一个系列。把每天学到的记录下来。 以实际的例子为主。

一、条件语句

if 语句

语法

#用法 1 
if condition1
then
  statement
elif condition2
then
  statement
fi
#用法 2 
if condition1; then
  statement
elif condition2; then
  statement
else
  statement
fi

例子

case 语句

二、循环语句

for 语句

while 语句

until 语句

与while 相反,当条件不满足时一直运行,直到条件为真

二、其他

And 和 Or

statement && statement
statement || statement

语句块

statement && {
  statement1
  statement2
  statement3
  ...
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!