> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bash Continue Statement

The `continue` statement is a built-in loop control command in Bash that immediately terminates the current iteration of an enclosing `for`, `while`, `until`, or `select` loop. Upon execution, it bypasses any remaining commands within the loop's body and transfers control back to the loop's condition evaluator, incrementer, or prompt to begin the next iteration.

```bash theme={"dark"}
continue [n]
```

## Parameter Mechanics

* **`n` (Optional):** An integer greater than or equal to `1` that specifies the depth of the loop hierarchy to target.
* **Default Behavior:** If `n` is omitted, it defaults to `1`, meaning the statement applies to the innermost enclosing loop.
* **Nested Targeting:** If `n` is provided (e.g., `continue 2`), Bash skips the remaining execution of the current loop *and* the remaining execution of the `n-1` enclosing loops, resuming at the next iteration of the `n`th enclosing loop.
* **Out-of-Bounds `n`:** If the specified `n` is greater than the total number of enclosing loops, the statement targets the outermost loop.

## Execution Flow Visualization

**Standard Continue (`n=1`)**
In a single-level loop, `continue` skips the remaining commands in the block and forces the loop to evaluate the next item or condition.

```bash theme={"dark"}
for i in {1..3}; do
    echo "Start iteration $i"
    
    if [[ $i -eq 2 ]]; then
        continue
    fi
    
    echo "End iteration $i"  # Bypassed when i equals 2
done
```

**Nested Continue (`n=2`)**
In a nested loop architecture, passing an integer dictates which loop's iteration is advanced.

```bash theme={"dark"}
outer=0
while [[ $outer -lt 2 ]]; do
    ((outer++))
    echo "Outer loop: $outer"
    
    for inner in {1..2}; do
        echo "  Inner loop: $inner"
        
        if [[ $inner -eq 1 ]]; then
            continue 2
        fi
        
        echo "  Inner end"  # Bypassed when inner equals 1
    done
    
    echo "Outer end"        # Bypassed when inner equals 1
done
```

*In the nested example, executing `continue 2` immediately halts the `for` loop, skips the remaining commands in the `while` loop block, and triggers the next iteration of the `while` loop.*

## Exit Status

The `continue` command yields an exit status of `0` (success) when executed within a valid loop context.

If invoked outside of a loop structure, Bash triggers a runtime warning message (e.g., `bash: continue: only meaningful in a 'for', 'while', or 'until' loop`) but still returns an exit status of `0`, and the script will continue executing subsequent lines.

The `continue` command only returns a non-zero exit status if the provided `n` argument is less than `1` (e.g., `continue 0`) or is a non-numeric value.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Bash Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
