Skip to main content

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.

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


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

# 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.
Master Bash with Deep Grasping Methodology!Learn More