# 流程控制

## if else

```bash
if [ expression ]; then
  statement
else
  statement
fi


if [ expression ]; then
  statement
elif [ expression ]; then
  statement
else
  statement
fi
```

## 循环

### for

```bash
for i in item1 item2 ... itemN
do
    statement
    ...
    statement
done

arr=(1 2 3)
for i in ${arr[@]}
do
    statement
    ...
    statement
done
```

### while

```bash
while condition
do
    command
done
```

无限循环

```bash
while :
do
  # command
done

while true do command done

for (( ; ; )) do command done
```

### until

```bash
until condition
do
    command
done
```

### 跳出循环

#### break

#### continue

## case

```bash
case $var in
  pattern)
    statement
    ;;
  *)
    statement
    ;;
esac
```
