> For the complete documentation index, see [llms.txt](https://linuxstory.gitbook.io/advanced-bash-scripting-guide-in-chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://linuxstory.gitbook.io/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches.md).

# 11. 循环与分支

> 奥赛罗夫人，您为什么把这句话说了又说呢？
>
> —— 《奥赛罗》，莎士比亚

### 本章目录

* [11.1 循环](/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches/11_1_loops.md)
* [11.2 嵌套循环](/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches/11_2_nested_loops.md)
* [11.3 循环控制](/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches/11_3_loop_control.md)
* [11.4 测试与分支](/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches/11_4_testing_and_branching.md)

对代码块的处理是结构化和构建 shell 脚本的关键。循环与分支结构恰好提供了这样一种对代码块处理的工具。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://linuxstory.gitbook.io/advanced-bash-scripting-guide-in-chinese/zheng-wen/part3/11_loops_and_branches.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
