> ## 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 Shift Command

The `shift` command is a Bash shell builtin that reassigns the positional parameters by shifting them to the left. When executed, the value of the positional parameter `$n+1` is assigned to `$1`, `$n+2` is assigned to `$2`, and so forth. This operation permanently discards the first *n* positional parameters from the current shell execution context and decrements the total parameter count (`$#`) by *n*.

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

## Mechanics and State Changes

* **Argument `n`:** An optional non-negative integer dictating the shift offset.
* **Default Behavior:** If `n` is omitted, the command defaults to `shift 1`. If `n` is `0`, no parameters are modified.
* **Immutability of `$0`:** The special parameter `$0` (the script or shell name) is strictly excluded from the shift operation and remains unchanged.
* **Parameter Count (`$#`):** The variable `$#` is dynamically updated to equal `$# - n`.
* **Unsetting Parameters:** The highest *n* positional parameters that previously held values are unset.

## Exit Status

* **`0` (Success):** The shift operation completes successfully, meaning `n` was less than or equal to `$#`.
* **`>0` (Failure):** If `n` is strictly greater than the current number of positional parameters (`$#`), the command fails. In this state, no positional parameters are modified, and `$#` remains unchanged.

## State Visualization

```bash theme={"dark"}

# Initial execution state: ./script.sh alpha bravo charlie delta echo

# $0 = "./script.sh"

# $1 = "alpha"

# $2 = "bravo"

# $3 = "charlie"

# $4 = "delta"

# $5 = "echo"

# $# = 5

shift 2


# Post-shift execution state:

# $0 = "./script.sh" (Unchanged)

# $1 = "charlie"     (Previously $3)

# $2 = "delta"       (Previously $4)

# $3 = "echo"        (Previously $5)

# $4 = unset

# $5 = unset

# $# = 3             (Decremented by 2)
```

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