标签:大于 变量 cut for color until col linux 循环
Shell for循环的语法如下所示
for 变量 in 列表 do command1 command2 ... commandN done
举例:
for i in {1..100} do echo $i done
类C语言也是可以的
for ((i=1; i<=100; i ++)) do echo $i done
while command do Statement(s) to be executed if command is true done
举例:
COUNTER=0 while [ $COUNTER -lt 5 ] do COUNTER=‘expr $COUNTER+1‘ echo $COUNTER done
说明:如果COUNTER小于5,那么返回 true。COUNTER从0开始,每次循环处理时,COUNTER加1,直到COUNT为5后终止。
until command do Statement(s) to be executed until command is true done
举例:
#!/bin/bash a=0 until [ ! $a -lt 10 ] do echo $a a=`expr $a + 1` done
说明:当【a不小于10】这个条件为假时,会在循环体内循环执行命令,也就是说,当a大于等于10时,才会跳出循环体。
这个脚本会输出0-9数字。
标签:大于 变量 cut for color until col linux 循环
原文地址:http://www.cnblogs.com/shuqingstudy/p/7490353.html