The | character is probably the symbol system administrators type most, and its story starts with an internal Bell Labs memo dated October 11, 1964. In it, Doug McIlroy asked for a way to connect programs like lengths of garden hose. The idea took almost nine years to reach Unix: pipes are first documented in the Third Edition manual of February 1973, after Ken Thompson implemented them, according to his colleagues, in a single night. Half a century later the mechanism is essentially the same, although its limits and its pitfalls have changed.
The Unix pipe in 20 seconds
- Doug McIlroy described the idea in a Bell Labs memo in October 1964.
- Ken Thompson added the pipe() call and shell notation; the Third Edition manual (February 1973) documents it.
- The first syntax reused >; | replaced it a few months later.
- Linux pipes hold 64 KB by default and guarantee atomic writes up to 4,096 bytes.
Before pipes, chaining two programs on Unix meant going through temporary files: the first wrote its output to disk, the second read it back and someone had to delete the intermediate file. With pipes, the kernel connects one process’s output directly to another’s input, both run at the same time and the system regulates the flow between them.
From McIlroy’s garden hose to Thompson’s all-nighter
The 1964 memo is a typed page that Dennis Ritchie kept on his office wall and that can still be read on Bell Labs’ historical site. It is the tenth page of a longer document, and it lists McIlroy’s priorities. The first is a way of connecting programs “like garden hose”, screwing in another segment when data needs to be massaged in another way. At the time, Bell Labs computing was mostly batch work on IBM 7090 and 7094 machines, and the Multics project was just starting.
Unix was born in 1969 on a PDP-7 and later moved to a PDP-11. According to Ritchie, the machine was ordered in May 1970, the processor arrived at the end of the summer and it had no disk until December. It had 24 KB of core memory, 16 KB for the system and 8 KB for user programs. Redirection with < and > already existed, but there was no way to connect two processes to each other.

In The Evolution of the Unix Time-sharing System, Ritchie explains that McIlroy had proposed years earlier treating commands as binary operators, with an input file on the left and an output file on the right. The idea was explained on a blackboard and nothing happened: there were objections to the notation, to the difficulty of separating parameters from files and to the one-input, one-output model. McIlroy’s persistence eventually paid off, and Ritchie describes installing pipes as a relatively simple job. In his interview with historian Michael S. Mahoney for the Princeton Unix oral history project, McIlroy admitted it was one of the few matters on which he very nearly exerted managerial control.
The accounts collected in that oral history agree on the pace. Thompson recalled that the idea simply hit him one night and that the changes needed were trivial. McIlroy added that the same night Thompson also changed the programs that only accepted file arguments so they would read standard input, and that the next morning the whole group was busy writing one-liners. McIlroy also told Mahoney that the idea of Unix as a toolbox did not exist before pipes: pipes created it.
The first syntax did not use the vertical bar
A detail often lost in the retelling is that the first operator was not |. Ritchie explains that pipes reused the redirection character, with this example to sort a file, paginate it and send it to the printer:
sort input >pr>opr>
Each > could be followed by a file or a command, and the final > was needed so that opr was treated as a command rather than a file name. The notation forced quoting of arguments containing spaces and was ambiguous because < was also accepted. According to Ritchie, it lasted only a couple of months before a dedicated operator replaced it. Brian Kernighan recalled in the oral history how preposterous the original syntax was until the vertical bar suddenly appeared. The same example became:
sort input | pr | opr

A widely shared story also claims the first pipe was exactly 512 bytes because Thompson mirrored an RK05 disk sector in memory. The primary sources consulted do not support it. The surviving Sixth Edition Unix source from 1975 shows something different: pipe() allocated an inode on the root device, and the PIPSIZ constant capped the size of the file implementing the pipe at 4,096 bytes. Data passed through the kernel buffer cache and, as administrators of the time noted on Usenet, could end up physically written to disk. From the Seventh Edition a separate pipe device could be configured, and 4.2BSD reimplemented pipes on top of sockets with a different buffering mechanism.

The number 512 does exist in today’s standard, but with a different meaning: POSIX requires PIPE_BUF, the largest write to a pipe guaranteed to be atomic, to be at least 512 bytes. It is a floor every system must meet, not the pipe’s capacity.
What to know about pipes on a modern Linux system
Capacity. According to the pipe(7) man page, up to Linux 2.6.11 a pipe held one memory page (4,096 bytes on x86), and since then it holds 16 pages, 65,536 bytes on a system with 4 KB pages. Since Linux 2.6.35 it can be queried and changed through fcntl() with F_GETPIPE_SZ and F_SETPIPE_SZ. Unprivileged users cannot exceed /proc/sys/fs/pipe-max-size, which defaults to 1,048,576 bytes. With Python 3.10 or later you can check it on any server:
python3 -c 'import os, fcntl; r, w = os.pipe(); print(fcntl.fcntl(w, fcntl.F_GETPIPE_SZ))'
# 65536
cat /proc/sys/fs/pipe-max-size
# 1048576
getconf PIPE_BUF /
# 4096Code language: PHP (php)
Atomicity. On Linux, PIPE_BUF is 4,096 bytes. When several processes write to the same pipe, each write of that size or smaller arrives whole, without being mixed with others; larger ones can interleave. That is why several processes can write short log lines into the same FIFO without them being cut, and why you should not rely on it for long messages.
SIGPIPE and exit code 141. If the reading process exits before the writer, the next write receives SIGPIPE (or EPIPE if the signal is ignored). That is what happens in yes | head -n 3: head exits after three lines and yes dies from SIGPIPE. In bash, a process killed by a signal reports 128 plus the signal number, so SIGPIPE (13) shows up as 141. This is normal behaviour, but in scripts using set -o pipefail it can make a pipeline that actually worked look like a failure.
A pipeline’s exit status. By default bash returns the status of the last command. A failing mysqldump followed by a successful gzip returns 0 and leaves you with an empty backup. pipefail changes the rule to return the last non-zero status, and the PIPESTATUS array holds the status of every stage:
false | true; echo $? # 0
set -o pipefail
false | true; echo $? # 1
mysqldump mydb | gzip > mydb.sql.gz
echo "${PIPESTATUS[@]}" # status of each stage, e.g. "2 0"Code language: PHP (php)
Buffering. Many programs write their output in blocks when they are not connected to a terminal, so in tail -f log | grep error | another_filter results can be slow to appear. Use grep --line-buffered or put stdbuf -oL in front of the command holding the output back. To see how much data is flowing through a long pipeline, pv shows throughput and progress without altering the data.
Named pipes. A FIFO created with mkfifo behaves like a pipe but has an entry in the filesystem, so unrelated processes can use it. Opening it for writing blocks until someone opens it for reading:
mkfifo /tmp/channel
gzip -c < /tmp/channel > dump.gz &
mysqldump mydb > /tmp/channel
rm /tmp/channelCode language: JavaScript (javascript)
The philosophy McIlroy later summed up, programs that do one thing well, work together and use text as a universal interface, still rests on this piece. It also carries a cost: the kernel knows nothing about what flows through a pipe, so every program has to parse the text it receives. PowerShell, for instance, chose object pipelines to avoid that.
Frequently asked questions
Who invented Unix pipes?
The idea came from Doug McIlroy, who described it in a 1964 Bell Labs memo. Ken Thompson implemented it in Unix, and the Third Edition manual of February 1973 already documents it.
How big is a pipe buffer on Linux?
65,536 bytes by default since Linux 2.6.11. It can be changed with fcntl and F_SETPIPE_SZ, up to /proc/sys/fs/pipe-max-size for unprivileged users.
What is PIPE_BUF?
The largest write the system guarantees will arrive without being mixed with others. POSIX requires at least 512 bytes and Linux uses 4,096.
Why does a script return 141 when using head?
Because the writing process received SIGPIPE when the reader closed, and bash reports 128 plus the signal number, 13.
Sources:
- Bell Labs: Advice from Doug McIlroy (1964 memo)
- Dennis M. Ritchie: The Evolution of the Unix Time-sharing System
- Princeton Unix Oral History: The Origin of Pipes
- The New Stack: Pipe, how the system call that ties Unix together came about
- Unix V6 source code: pipe.c
- TUHS, comp.unix.wizards (1985): pipes and the root filesystem
- Linux man-pages: pipe(7)
