国际访客建议访问 Primers 编程伙伴 国际版站点 > Bash 教程 > continue 以获得更好的体验。

# Bash 的 continue 命令

continue [N]

!subtitle:功能

结束本轮循环,继续下一轮循环。

!subtitle:类型

Bash 内置命令。

!subtitle:参数

  • N - 继续第 N 层循环的下一轮;默认为 1

# 示例

运行示例

for ((x=0; x<10; x=x+1)); do
    for ((y=0; y<10; y=y+1)); do
        for ((z=0; z<10; z=z+1)); do
            echo $x $y $z
            continue 3                  # 继续第 3 层循环的下一轮
        done
    done
done

# 相关命令

命令 说明
break 跳出循环

# 推荐阅读

# 手册

continue: continue [n]
    Resume for, while, or until loops.

    Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
    If N is specified, resumes the Nth enclosing loop.

    Exit Status:
    The exit status is 0 unless N is not greater than or equal to 1.
本文 更新于: 2025-11-27 09:38:14 创建于: 2025-11-27 09:38:14