> ## 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 Process Substitution Output

The `>(...)` operator in Bash represents **output process substitution**. It allows a command to write to another process as if it were writing to a physical file. When Bash encounters this operator, it executes the enclosed command in a background subshell, connects its standard input (`stdin`) to a pipe, and replaces the entire `>(...)` expression with the file path to that pipe's write file descriptor.

*Note: Process substitution is a shell extension found in Bash, Zsh, and Ksh. It is not POSIX `sh` compliant and will cause syntax errors if executed in standard `#!/bin/sh` scripts.*

## Syntax and Usage

```bash theme={"dark"}

# tee writes to stdout and to the file path provided by >(...)
echo "hello" | tee >(cat > output.txt)
```

*Note: There must be absolutely no space between the `>` and the `(`. A space changes the parser's interpretation to standard output redirection followed by a syntax error.*

Because `>(...)` strictly yields a file path string, developers often mistakenly assume it will automatically capture a command's standard output. To redirect `stdout` into the substituted process, it must be explicitly combined with the standard output redirection operator (`>`), resulting in the `> >(...)` idiom:

```bash theme={"dark"}

# Redirecting standard output (>) into the process substitution (>(...))
echo "hello" > >(sed 's/hello/world/' > output.txt)
```

## Execution Mechanics

When a command utilizing output process substitution is invoked, the shell performs the following sequence:

1. **Allocation:** Bash creates an anonymous pipe using the `pipe()` system call.
2. **Process Creation:** Bash spawns the enclosed command asynchronously. The `stdin` of this new process is attached to the read end of the pipe.
3. **Expansion:** Bash performs process substitution as one of its standard shell expansions (prior to execution). It replaces the literal text `>(...)` in the original command line with the constructed string `/dev/fd/<N>` (where `<N>` is the allocated write file descriptor).
4. **Execution:** The parent command executes, treating `/dev/fd/<N>` as a standard file argument. As the parent command writes to this path, the kernel buffers the data and streams it directly into the `stdin` of the enclosed process.

## Technical Characteristics

* **Asynchrony:** The process inside the parentheses runs asynchronously. The parent shell does not inherently wait for the `>(...)` process to terminate before moving to the next command in a script.
* **Subshell Isolation:** Because the enclosed command runs in a subshell, any state changes (such as variable assignments, `cd`, or `shopt` modifications) made inside the parentheses are destroyed once the process terminates. They do not affect the parent shell.
* **File-like Abstraction:** Unlike standard piping (`|`), which connects the `stdout` of one command directly to the `stdin` of another, process substitution provides a literal file path argument. This is structurally required for commands that strictly expect a file path parameter rather than reading from standard input.
* **Directionality:** The `>` indicates the flow of data *into* the process. It is the inverse of `<(...)` (input process substitution), which provides a file path for the parent command to *read* from.

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