> ## 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 Pattern Substitution

The `/` character in Bash serves two primary operator roles depending on the evaluation context: the **arithmetic division operator** and the **pattern substitution operator** in parameter expansion. Additionally, it functions lexically as the system path separator.

## Arithmetic Division Operator

Within native arithmetic evaluation contexts (`$((...))`, `((...))`, and `let`), `/` functions as the integer division operator. Because Bash lacks native floating-point support, the operation strictly performs integer division, truncating any fractional remainder towards zero.

**Syntax:**

```bash theme={"dark"}
$(( dividend / divisor ))
```

**Technical Characteristics:**

* **Truncation:** The operation discards remainders. `10 / 3` evaluates to `3`. `-10 / 3` evaluates to `-3`.
* **Division by Zero:** Attempting to divide by zero triggers a runtime error (`division by 0 (error token is "0")`). In non-interactive shells (such as standard Bash scripts), this is a fatal error that immediately aborts the execution of the entire script.
* **Precedence:** Evaluates left-to-right. It shares the same precedence level as multiplication (`*`) and modulo (`%`), which is strictly higher than addition (`+`) and subtraction (`-`).

## Parameter Expansion (Pattern Substitution) Operator

Within curly brace parameter expansion, `/` acts as the delimiter for pattern matching and string substitution. It instructs the Bash interpreter to search the expanded value of a variable for a specific glob pattern and replace it.

**Syntax:**

```bash theme={"dark"}
${parameter/pattern/string}
```

**Operator Variations:**

* **Single Slash (`/`):** Replaces only the *first* longest match of `pattern` with `string`.
* **Double Slash (`//`):** Acts as a global substitution operator, replacing *all* matches of `pattern` with `string`.
* **Slash-Hash (`/#`):** Anchors the match to the *beginning* (prefix) of the expanded parameter.
* **Slash-Percent (`/%`):** Anchors the match to the *end* (suffix) of the expanded parameter.

**Technical Characteristics:**

* **Deletion:** If the `string` and its preceding `/` are omitted (e.g., `${parameter/pattern}`), the matched pattern is deleted (replaced with a null string).
* **Globbing Rules:** The `pattern` is evaluated using standard Bash pattern matching (globbing) rules. Characters like `*`, `?`, and `[...]` act as wildcards. To match literal wildcard characters, they must be escaped or quoted.
* **Immutability:** The operation is non-destructive. It evaluates to the modified string but does not mutate the original variable in memory.

## Path Separator (Lexical Context)

Outside of arithmetic and parameter expansion contexts, `/` is parsed lexically as the root directory indicator and hierarchical path separator. Along with the null byte (`\0`), it is one of only two characters strictly prohibited within a filename by the Linux kernel and POSIX standards, as the shell reserves it for traversing directory trees during pathname expansion and command resolution.

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