DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

Bash Process Substitution: A Little-Known Way to Pass Command Output as a File

Bash process substitution lets file-only commands read another command's output or feed it input, using (list) instead of temporary files.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bash process substitution lets a command that expects file arguments read the output of another command, or write its input to another command, without you creating a temporary file. You write <(list) to read a process’s output as if it were a file, or >(list) to write to a file-like name that feeds a process’s input. It is Bash shell syntax, not a kernel feature that every shell provides, and it needs system support for named pipes (FIFOs) or the /dev/fd method.

What the two forms do

The GNU Bash Reference Manual describes the construct this way: “The process list is run asynchronously, and its input or output appears as a filename.” In practice, Bash starts the commands inside the parentheses, and hands the command on the left a filename-like reference connected to them. Which direction the data travels depends on which form you use.

As an Amazon Associate I earn from qualifying purchases.

Form Direction What the outer command sees Typical use
<(list) Output of list flows into the outer command A readable filename whose contents are list‘s standard output Giving a file-only tool the output of a generated stream
>(list) Data written by the outer command flows into list A writable filename; anything written to it becomes list‘s standard input Sending one stream to a second process while the main command runs

Read the table from the perspective of the command that receives the filename. With <(...), that command reads. With >(...), that command writes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The no-space rule

The angle bracket must touch the opening parenthesis. <(sort names.txt) is process substitution. < (sort names.txt) is not: Bash parses the < as an input redirection, and the parenthesis that follows is no longer the construct you intended. Expect a syntax error or a result you did not plan for. The same rule applies to >(...).

A worked comparison

The most common illustration is comparing the sorted contents of two files with a tool that accepts file operands, such as diff:

diff <(sort first.txt) <(sort second.txt)

Each <(...) runs its sort in the background and gives diff a filename to open. diff never sees an intermediate file on disk, and you do not have to name or clean up sorted_first.txt and sorted_second.txt yourself. The same pattern works with other file-oriented tools, such as comm or paste, when they accept file operands. This is an illustrative example of the documented data flow; the outcome depends on the contents of your files and your Bash version.

Writing into a process with >(...)

The output form is less common but works in the same way. The outer command writes to a filename, and the listed process reads that data as standard input. A short illustration using tee, which copies its input to every file operand it receives:

printf '%sn' alpha beta gamma | tee >(wc -l >&2) >/dev/null

Here tee writes the lines to the substitution, where wc -l counts them, and sends the copy on standard output to /dev/null. Because the listed process runs asynchronously, its output can appear after the main command finishes, which matters when you build pipelines that depend on ordering.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why you may see a /dev/fd path

When you run echo <(true) you will typically see a path such as /dev/fd/63. This is the /dev/fd mechanism at work: the operating system exposes an open file descriptor under a path name, and Bash passes that path to the command. Other systems use a named pipe in a temporary location instead. The exact path is an implementation detail, so do not write scripts that depend on a particular number or location.

What your system must support

The Bash manual states that process substitution is available on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. On a typical modern Linux system with Bash, both are normally present. The constraint matters in a few specific situations:

  • Other shells: Bash-specific syntax is not part of the POSIX shell language. A script that starts with #!/bin/sh on a system where sh is dash will fail on <(...). Use #!/usr/bin/env bash or #!/bin/bash and run the script with Bash explicitly.
  • Restricted or unusual environments: Some containers, chroots, or hardened systems may lack /dev/fd or FIFO support. Test in the target environment rather than assuming availability.
  • Commands that require a seekable file: Tools that seek or reopen their input may behave differently when given a pipe-like reference rather than a regular file.

The manual does not provide a complete table of which shells, distributions, or container images support the feature, so verify on the system you deploy to.

Process substitution versus command substitution

Command substitution, written $(command), runs a command and replaces itself with its captured standard output, with trailing newlines removed. The result is a string value that you can assign to a variable or pass as an argument. Process substitution does not produce a string. It produces a filename connected to a running process. Choose command substitution when you need the text itself, and process substitution when the receiving command insists on a file operand.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • Syntax error near (: Check for a space between < or > and (.
  • “/dev/fd: No such file or directory” or similar: The environment probably lacks /dev/fd. Check with ls -l /dev/fd.
  • Works in your terminal but fails in a script: The script is probably running under sh rather than Bash. Confirm the interpreter line and run bash script.sh to test.
  • Output missing or out of order when using >(...): The listed process runs asynchronously. Add an explicit wait or restructure the script if the outer command must finish its work only after the consumer has completed.

Further learning

Process substitution is one of several Bash features that reduce temporary files. A Bash scripting book or the Bash shell reference will cover it alongside pipes, redirections, and file descriptors, which together explain why the syntax behaves as it does.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

Use <(command) when a file-only tool needs to read a command’s output, and >(command) when a command needs to write into another process. Keep the bracket attached to the parenthesis, run the script under Bash, and confirm that the target system supports FIFOs or /dev/fd.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.