continue-nlevel.sh

来自「Shall高级编程」· Shell 代码 · 共 31 行

SH
31
字号
#!/bin/bash# The "continue N" command, continuing at the Nth level loop.for outer in I II III IV V           # outer loopdo  echo; echo -n "Group $outer: "  # --------------------------------------------------------------------  for inner in 1 2 3 4 5 6 7 8 9 10  # inner loop  do    if [ "$inner" -eq 7 ]    then      continue 2  # Continue at loop on 2nd level, that is "outer loop".                  # Replace above line with a simple "continue"                  # to see normal loop behavior.    fi      echo -n "$inner "  # 7 8 9 10 will never echo.  done    # --------------------------------------------------------------------doneecho; echo# Exercise:# Come up with a meaningful use for "continue N" in a script.exit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?