# 1.7 循环判断

## if-else

```shell
#!/bin/bash
if condation
then
	command
fi  # 结束


if condation
then
	command
else	
	command
fi  # 结束


if condation
then
	command
elif	
	command
else	
	command
fi  # 结束

```

## for

```shell
#!/bin/bash
for loop in 1 2 3 4 5
do
    echo "The value is: $loop"
done
```

## while

```shell
#!/bin/bash
while condition
do
    command
done
```

## until

> until 循环执行一系列命令直至条件为 true 时停止

```shell
#!/bin/bash
until condition
do
    command
done
```

## case-esac

```shell
case 值 in
模式1)
    command1
    ;;
模式2)
    commandN
    ;; # 结束符
esac
```

## 跳出循环

* break 命令
* continue


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jtz.gitbook.io/web-security/bian-cheng-yu-yan/shell-jiao-cheng/1.7-xun-huan-pan-duan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
