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

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

## Syntax

The operator is utilized within the `test` command, the POSIX-compliant single bracket `[ ]`, or the Bash-specific extended test keyword `[[ ]]`.

```bash theme={"dark"}

# POSIX-compliant test command
test INT1 -le INT2


# POSIX-compliant single bracket
[ INT1 -le INT2 ]


# Bash extended test keyword
[[ INT1 -le INT2 ]]
```

## Technical Mechanics

* **Operand Constraints:** The `-le` operator strictly requires integer evaluation; Bash does not natively support floating-point arithmetic. The behavior upon encountering invalid types depends on the context:
  * In `[ ]` and `test`: Operands must be strictly integer literals. Passing a floating-point number (e.g., `2.5`) or a non-numeric string results in a runtime error (`bash: [: <value>: integer expression expected`) and yields an exit status of `2`.
  * In `[[ ]]`: Operands undergo arithmetic evaluation. Passing a standard non-numeric string (e.g., `"abc"`) does not inherently throw an error; instead, Bash treats the string as a variable name within an arithmetic context. If the variable is unset, it silently evaluates to `0`. A syntax error is only triggered if the string contains fundamentally invalid arithmetic syntax (e.g., `"a b"` or `2.5`), yielding an exit status of `1`.
* **Empty Variable Handling:**
  * In the POSIX `[ ]` context, an unquoted empty variable results in a syntax error due to a missing expected argument. A quoted empty string (`""`) yields an `integer expression expected` error.
  * In the extended `[[ ]]` context, an unset variable referenced strictly by name (e.g., `[[ var -le 2 ]]`) implicitly evaluates to the integer `0`. Conversely, an empty string literal or an expanded empty variable (e.g., `[[ "" -le 2 ]]` or `[[ $var -le 2 ]]`) causes an arithmetic syntax error (`bash: [[: : syntax error: operand expected`).
* **Base Representation:**
  * In `[ ]` and `test`: Operands are strictly parsed as base 10. A leading `0` does not trigger octal interpretation (e.g., `010` is evaluated as `10`), and hexadecimal prefixes (e.g., `0x10`) result in an `integer expression expected` error.
  * In `[[ ]]`: Because operands are subjected to arithmetic evaluation, standard Bash integer bases apply. A leading `0` is interpreted as octal, and a leading `0x` is interpreted as hexadecimal.

## Evaluation Differences vs. Arithmetic Expansion

While `-le` serves the same logical purpose as the `<=` operator used within Bash's arithmetic expansion context `(( ))`, their evaluation mechanics differ significantly.

```bash theme={"dark"}
[ "$a" -le "$b" ]
(( a <= b ))
```

In the `[ ]` construct, `-le` strictly requires integer literals. If a variable contains an arithmetic expression (e.g., `a="1+1"`), `[ ]` will throw an error. In contrast, `(( ))` performs full arithmetic evaluation, successfully resolving `1+1` to `2` before the comparison. Furthermore, `(( ))` treats non-numeric strings as variable names or `0`, whereas `[ ]` throws an error.

*Note: Do not confuse `-le` with the `<` or `>` operators inside `[[ ]]`. The `-le` operator performs mathematical integer comparisons, whereas `<` and `>` perform lexicographical (string) comparisons based on the current locale's collating sequence. Bash does not support a `<=` operator inside `[[ ]]`.*

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