> For the complete documentation index, see [llms.txt](https://jtz.gitbook.io/web-security/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jtz.gitbook.io/web-security/bian-cheng-yu-yan/shell-jiao-cheng/1.7-xun-huan-pan-duan.md).

# 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
