tee, one stream per page
Twenty-eight lessons on the tee command, one stream per page: the standard streams stdin, stdout and stderr; the pipe and the pipeline; tee reading standard input and writing to the file and to standard output; the -a append flag and the junction as plumbing; tee inside pipelines and logging while piping; tee with sudo writing privileged files, tee against plain redirection and process substitution; error streams joined with 2>&1, buffering and the log that lies, the cat contrast, many files at once and the /dev/null sink; and teaching a friend one honest hour.
One stream, one page, one honest hour. That's the rhythm.
tee, one stream per page
Twenty-eight lessons on the tee command, one stream per page: the standard streams stdin, stdout and stderr; the pipe and the pipeline; tee reading standard input and writing to the file and to standard output; the -a append flag and the junction as plumbing; tee inside pipelines and logging while piping; tee with sudo writing privileged files, tee against plain redirection and process substitution; error streams joined with 2>&1, buffering and the log that lies, the cat contrast, many files at once and the /dev/null sink; and teaching a friend one honest hour.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
Every fact in this book is as the official source states it, fetched and read during this build: the local manual pages tee(1), cat(1) and sudo(8) (GNU coreutils 9.4 for tee and cat), the definition of truth for this book, and the Wikipedia articles Tee (command), Standard streams, Pipeline (Unix), Redirection (computing), Process substitution, Null device, Data buffer, Cat (Unix) and Sudo. No facts are sourced from Reddit, Stack Overflow, vendor blogs or commercial sites. Every command and output pair was run on this machine with temporary files under the build scratch directory only, each capture cached verbatim so the pair is reproducible. SAFETY LAW: no file outside the book directory's scratch area was written by any demonstration; every run was read-only toward the rest of the machine, and sudo was never invoked for writes, the root-file demonstration being a labeled plain simulation on a scratch file. Honest notes: the Wikipedia title Tee (Unix) is a redirect stub, so it was followed and read at its redirect goal (Tee (command)); /dev/null redirected to Null device, also followed and read; and the cached titles Buffer (disk caching) and Ts (utility) answered 404 and are not used. An independent guide, not affiliated with or endorsed by the Free Software Foundation, the IEEE, or the Wikimedia Foundation.
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
Per the Wikipedia Tee (command) article, the name derives from the tee pipe fitting, even though the tee command duplicates the input into each output instead of dividing the input into portions for each output. The article infobox lists the first release year as 1974 and the Linux version as written by Mike Parker, Richard Stallman, and David MacKenzie.
The T fitting
The name is plumbing. Per the Wikipedia Tee (command) article, the name derives from the tee pipe fitting, the T that lets one pipe feed two.
But the article is precise about the difference: tee duplicates the input into each output instead of dividing the input into portions for each output. Nothing is split. Every destination gets the whole stream.
The infobox dates it to 1974; the Linux version came from Mike Parker, Richard Stallman and David MacKenzie.
Draw the T fitting on paper, mark the whole stream reaching both arms, and caption it with the word duplicates.
Per the Wikipedia Tee (command) article, -a means append to a file rather than overwriting, and the file is created if it was not pre-existing. This machine's capture: tee log.txt then tee -a log.txt left cat log.txt printing first line and then second line.
Append with -a
One flag changes the ethics. Per the article, -a means append to a file rather than overwriting, and the file is created if it was not pre-existing.
Our capture: printf "first line" | tee log.txt, then printf "second line" | tee -a log.txt. The cat answered first line, then second line. Both runs kept.
A log that grows instead of resetting: that is what -a buys, and it costs one letter.
Send two lines into one log one minute apart, the second with -a, then read the log and find both.
Per the Wikipedia Tee (command) article, file... means one or more names for files to receive the command input data, and tee copies data from standard input to one or more files in addition to standard output, duplicating the input to each output. This machine's capture: printf "one stream" | tee a.txt b.txt c.txt, and cat a.txt b.txt c.txt printed one stream three times.
Many files at once
Name them all. Per the article, file... means one or more names for files to receive the command input data, and tee duplicates the input to each output.
Our capture: printf "one stream" | tee a.txt b.txt c.txt printed the line once on screen, and cat a.txt b.txt c.txt answered one stream three times.
Three files, one pass, no loop. The duplicator, not the divider, exactly as the fitting promised.
Fan one line through tee into three files, then cat all three in one command and count the copies.
Per the Wikipedia Tee (command) article, its example pipes a public key into sudo tee -a /root/.ssh/authorized_keys2 over ssh with the stdout stream dumped into /dev/null to suppress the console output. This machine's capture is a labeled simulation of the same shape with a scratch file; no sudo was invoked.
The root file write
The article's one-liner, decoded: a key piped into sudo tee -a /root/.ssh/authorized_keys2 with the echo dumped into /dev/null to hush the console. Append, so existing keys survive.
Our capture is a labeled simulation: printf "ssh-rsa..." | tee -a rootkeys.sim > /dev/null on a scratch file, no sudo invoked. The file gained the line; the screen stayed quiet.
Three moves in a row: the pipe carries it, tee -a appends it, the null sink quiets it.
Trace the article's shape on paper, label each of the three moves, then run the simulation shape yourself.
Per the Wikipedia Null device article, the null device is typically used for disposing of unwanted output streams of a process. Per the Wikipedia Pipeline (Unix) article, the standard error streams of the processes in a pipeline are not passed on through the pipe; instead they are merged and directed to the console. This machine's capture: ls nosuchfile 2> /dev/null | tee quiet.log stayed silent and quiet.log came back empty.
Quiet the noise
You already know the sink. Per the Null device article it is typically used for disposing of unwanted output, and per the Pipeline article a pipeline's error streams are not passed on through the pipe anyway; they go to the console.
So the hush is aimed: 2> /dev/null. Our capture: ls nosuchfile 2> /dev/null | tee quiet.log ran silent, and quiet.log came back empty.
Silence on purpose, never by accident: send stream 2 to the sink yourself, and the log stays clean.
Hush one command's errors into the null device before teeing its output, and confirm the log holds only the good stream.
Per the Wikipedia Standard streams article, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered, so text written to standard error later may appear on the terminal earlier if the standard output stream buffer is not yet full. This machine's capture: the mid-run read of the tee file saw half a log. Per the Wikipedia Pipeline (Unix) article, both processes run concurrently.
The lying log
The red truth about timing. Per the Wikipedia Standard streams article, stderr is often unbuffered while stdout is line-buffered, so text written to stderr later may appear on the terminal earlier.
Our buffer capture showed the file side: mid-run, the log held half the story, and the pipeline had not finished.
A log read mid-flight is not the truth yet. Wait for the prompt, then read; that is the discipline.
Rerun the slow two-stage capture, read the log too early once, then again after, and say what changed.
Per this book's plan, the last lesson hands tee to a friend in one honest hour: five captured lines from this book, typed by the learner, read aloud by the teacher. The captures behind the five lines: hello tee twice, the overwrite trap, the append pair, gamma with mid.txt, and the 6 and 3 substitution answers.
Teaching tee
The last stream is passing the tool on, one friend, one honest hour, per this book's plan.
They type; you read aloud. The five lines are this book's captures: printf "hello tee" | tee hello.txt, the trap that kept only second run, the -a pair that kept both, the tee mid.txt | grep am tap, and the substitution answering 6 and 3.
When they can say why the trap lost the first line, the hour is done and the junction is theirs.
Sit with one friend and teach tee in one sitting; they type the five lines, you read each answer aloud.