GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — linux-command/command/continue.md at master · javamickey/linux-command

Expand file tree

/

continue.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
70 lines (53 loc) · 1.11 KB
/

continue.md

Copy path

File metadata and controls

70 lines (53 loc) · 1.11 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

continue

结束本次循环,继续执行下一个for,while或until循环。

概要

continue [n]

主要用途

  • 结束本次循环,继续执行下一个for,while或until循环;可指定从第几层循环继续执行。

参数

n(可选):大于等于1的整数,用于指定从第几层循环继续执行。

返回值

返回状态为成功除非n小于1。

例子

# continue的可选参数n缺省值为1。
for((i=3;i>0;i--)); do
  # 跳到内层for循环继续执行。
  for((j=3;j>0;j--)); do
    if((j==2)); then
      # 换成continue 1时结果一样
      continue
    fi
  printf "%s %s\n" ${i} ${j}
  done
done
# 输出结果
3 3
3 1
2 3
2 1
1 3
1 1
# 当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}
  done
done
# 输出结果
3 3
2 3
1 3

注意

  1. 该命令是bash内建命令,相关的帮助信息请查看help命令。
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.