上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 40 下一页
摘要: 在循环过程中,有时候需要在未达到循环结束条件时强制跳出循环,像大多数编程语言一样,Shell也使用 break 和 continue 来跳出循环。break命令break命令允许跳出所有循环(终止执行后面的所有循环)。下面的例子中,脚本进入死循环直至用户输入数字大于5。要跳出这个循环,返回到shel... 阅读全文
posted @ 2014-10-14 02:28 wuhn 阅读(430) 评论(0) 推荐(0) 编辑
摘要: until 循环执行一系列命令直至条件为 true 时停止。until 循环与 while 循环在处理方式上刚好相反。一般while循环优于until循环,但在某些时候,也只是极少数情况下,until 循环更加有用。until 循环格式为:until commanddo Statement(s)... 阅读全文
posted @ 2014-10-14 02:13 wuhn 阅读(334) 评论(0) 推荐(0) 编辑
摘要: while循环用于不断执行一系列命令,也用于从输入文件中读取数据;命令通常为测试条件。其格式为:while commanddo Statement(s) to be executed if command is truedone命令执行完毕,控制返回循环顶部,从头开始直至测试条件为假。以下是一个... 阅读全文
posted @ 2014-10-14 02:10 wuhn 阅读(3590) 评论(0) 推荐(0) 编辑
摘要: How do I use bash for loop to repeat certain task under Linux / UNIX operating system? How do I set infinite loops using for statement? How do I use t... 阅读全文
posted @ 2014-10-14 02:04 wuhn 阅读(598) 评论(0) 推荐(0) 编辑
摘要: echo -e "a\tb\tc\nd\te\tf"加-e 阅读全文
posted @ 2014-10-14 01:31 wuhn 阅读(8095) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashnum1=1num2=2num3=3#echo $($num1+$num2+$num3)#错误写法echo $[$num1+$num2+$num3]echo $(($num1+$num2+$num3))echo $(expr $num1 + $num2 + $num3 ) 阅读全文
posted @ 2014-10-14 01:30 wuhn 阅读(5628) 评论(0) 推荐(0) 编辑
摘要: :<<EOF注释的代码...EOF单行是# 阅读全文
posted @ 2014-10-14 01:26 wuhn 阅读(918) 评论(0) 推荐(0) 编辑
摘要: 与其他编程语言类似,Shell支持for循环。for循环一般格式为:for 变量 in 列表do command1 command2 ... commandNdone列表是一组值(数字、字符串等)组成的序列,每个值通过空格分隔。每循环一次,就将列表中的下一个值赋给变量。in ... 阅读全文
posted @ 2014-10-14 01:21 wuhn 阅读(6881) 评论(0) 推荐(0) 编辑
摘要: case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构。case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令。case语句格式如下:case 值 in模式1) command1 command2 command3 ... 阅读全文
posted @ 2014-10-14 00:50 wuhn 阅读(390) 评论(0) 推荐(0) 编辑
摘要: if 语句通过关系运算符判断表达式的真假来决定执行哪个分支。Shell 有三种 if ... else 语句:if ... fi 语句;if ... else ... fi 语句;if ... elif ... else ... fi 语句。1) if ... else 语句if ... else ... 阅读全文
posted @ 2014-10-14 00:23 wuhn 阅读(583) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 40 下一页