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

The `-eq` operator is a binary arithmetic comparison operator in Bash used to evaluate numerical equality between two integer operands. It returns an exit status of `0` (true) if the resolved integer values of both operands are mathematically equal, and `1` (false) otherwise.

**Syntax**
The operator requires two operands and must be executed within a test construct, such as the POSIX `test` command, the standard test brackets `[ ]`, or the extended test brackets `[[ ]]`:

```bash theme={"dark"}
[ operand1 -eq operand2 ]
[[ operand1 -eq operand2 ]]
test operand1 -eq operand2
```

**Evaluation Contexts**
The parsing rules, type strictness, and radix resolution of `-eq` are not inherent to the operator itself; they depend entirely on the enclosing command construct.

*Standard Test (`[` and `test`)*

* **Strict Base-10 Parsing:** Operands are evaluated strictly as base-10 integers. Leading zeros are ignored, meaning the literal `010` is parsed as decimal `10`, not octal `8`.
* **Type Strictness:** Passing non-numeric strings or floating-point numbers (e.g., `3.14`) triggers an `integer expression expected` error and immediately returns an exit status of `2`.

*Extended Test (`[[ ]]`)*

* **Arithmetic Evaluation:** Operands are evaluated dynamically as arithmetic expressions. Variables do not require the `$` prefix for dereferencing.
* **Radix/Base Resolution:** Bash integer bases are actively interpreted. A leading `0` denotes an octal value (e.g., `010` evaluates to decimal `8`), and a leading `0x` denotes hexadecimal.
* **String Handling:** Non-numeric strings (e.g., `"foo"`) are treated as variable names. If the referenced variable is unset, it evaluates to `0` without throwing an error. Consequently, `[[ "foo" -eq 0 ]]` evaluates to true.
* **Floating-Point Error:** Because Bash lacks native floating-point support, passing a float (e.g., `3.14`) triggers an arithmetic syntax error and returns an exit status of `1`.

**Exit Status Codes**

* `0`: Operands are mathematically equal.
* `1`: Operands are not mathematically equal, or an arithmetic syntax error occurred within `[[ ]]`.
* `2` (or higher): Evaluation failure within `[` or `test` due to syntax errors, missing operands, or invalid data types.

**Contrast with String Equality**
The `-eq` operator utilizes a fundamentally different evaluation engine than the `=` or `==` operators, which perform lexicographical string comparisons. Because `-eq` parses operands numerically, it evaluates `05` and `5` as equal. Conversely, the `==` operator evaluates `05` and `5` as unequal because their literal character sequences differ.

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