> ## 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 Integer Greater Than Or Equal

The `-ge` operator is a binary integer comparison operator in Bash that evaluates whether the left operand is mathematically greater than or equal to the right operand. It yields an exit status of `0` (true) if the condition is satisfied, and `1` (false) otherwise.

## Syntax

The operator is utilized within the `test` builtin, the POSIX test command (`[`), or the Bash extended test keyword (`[[`).

```bash theme={"dark"}

# POSIX standard test syntax
[ INT1 -ge INT2 ]
test INT1 -ge INT2


# Bash extended test syntax
[[ INT1 -ge INT2 ]]
```

## Technical Characteristics

The behavior of the `-ge` operator diverges significantly depending on the enclosing test construct:

* **Arithmetic Evaluation:**
  * Within the POSIX `[` construct, operands are strictly parsed as literal integers.
  * Within the extended `[[` construct, operands to `-ge` undergo arithmetic evaluation before comparison. This means mathematical expressions are dynamically resolved, making syntax like `[[ "1+2" -ge 3 ]]` perfectly valid.
* **Type Constraints and Error Handling:** Bash does not natively support floating-point arithmetic, but the resulting errors depend on the construct used.
  * **In `[`:** Passing a non-integer string or a float to `-ge` causes Bash to throw an `integer expression expected` error.
  * **In `[[`:** Passing a float (e.g., `"1.5"`) throws a `syntax error: invalid arithmetic operator`. However, a non-integer string (e.g., `"foo"`) is treated as a variable name due to the arithmetic evaluation context.
* **Variable Expansion and Empty Strings:**
  * **In `[`:** Operands should be quoted (e.g., `[ "$a" -ge "$b" ]`). If an unquoted variable is empty or unset, the shell expands it to nothing. This leaves the command missing its left operand (e.g., `[ -ge 5 ]`), causing `[` to parse `-ge` incorrectly and throw a specific command error: `bash: [: -ge: unary operator expected`. If quoted and empty (`[ "" -ge 5 ]`), it throws an `integer expression expected` error.
  * **In `[[` with `$var`:** If an unset or empty variable is referenced with a `$` (e.g., `[[ $a -ge 0 ]]`), it expands to an empty string `""`. The arithmetic evaluator cannot process an empty string and throws a syntax error: `bash: [[: : syntax error: operand expected (error token is "")`.
  * **In `[[` with unquoted names:** If a variable is referenced by name without the `$` (e.g., `[[ a -ge 0 ]]`), its behavior depends strictly on its state. If the variable is explicitly set to an empty string (`a=""`), Bash throws the exact same `syntax error: operand expected`. Only an *unset* variable referenced by name (or a variable containing a string that matches an unset variable's name) safely evaluates to `0` without throwing an error.
* **Contextual Limitation:** `-ge` is specifically designed for the `test` (`[`) and extended test (`[[`) constructs. It is not used within arithmetic evaluation contexts (`(( ))`); the arithmetic equivalent is the `>=` operator.

## Evaluation Matrix

The following table demonstrates the evaluation of various expressions using the `-ge` operator:

| Expression              | Exit Status | Boolean Result | Notes                                               |
| :---------------------- | :---------- | :------------- | :-------------------------------------------------- |
| `[[ 10 -ge 5 ]]`        | `0`         | True           | Standard integer comparison.                        |
| `[[ 5 -ge 5 ]]`         | `0`         | True           | Equality satisfies the condition.                   |
| `[[ 5 -ge 10 ]]`        | `1`         | False          | Left operand is lesser.                             |
| `[[ -2 -ge -5 ]]`       | `0`         | True           | Handles negative integers.                          |
| `[[ "2+3" -ge 5 ]]`     | `0`         | True           | Arithmetic evaluation resolves `"2+3"` to `5`.      |
| `[[ unset_var -ge 0 ]]` | `0`         | True           | Unset variable referenced by name evaluates to `0`. |

## Operator Equivalency

To understand `-ge` within the broader Bash operator ecosystem, it is the arithmetic counterpart to string comparison operators, but strictly for numeric evaluation:

```bash theme={"dark"}

# Integer comparison (Greater than or equal to)
[[ "$int1" -ge "$int2" ]]


# String comparison (Lexicographical greater than or equal to)

# Note: Requires escaping in [ ] but not in [[ ]]
[[ "$str1" > "$str2" || "$str1" == "$str2" ]]


# Arithmetic context equivalent
(( int1 >= int2 ))
```

<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>
