1、命令简介
continue:继续循环for、while、until或select的下一次迭代。
2、命令用法
continue [n]
3、命令选项
选项 | 描述 |
[n] | 如果提供了n,则退出第n个循环。n必须大于等于1。返回状态为0,除非n不大于等于1。 |
4、使用示例
1)创建脚本
#continue的可选参数n缺省值为1:for((i=3;i>0;i--)); do for((j=3;j>0;j--)); do if((j==2)); then continue fi printf "%s %s\n" ${i} ${j} done done #当n为2时跳到外层for循环继续执行:for((i=3;i>0;i--)); do for((j=3;j>0;j--)); do if((j==2)); then continue 2 fi printf "%s %s\n" ${i} ${j} donedone
2)运行脚本
$ chmod a+x continuesample$ ./continuesample3 33 12 32 11 31 13 32 31 3