← All 157 books tee, one stream per page
One stream per page

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.


Steve Hodgkiss 7 lessons

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

Contents


Part 1 · The three streams
The T fitting4
Part 2 · The plain run
Append with -a5
Part 3 · The arrow
Many files at once6
Part 4 · The pipeline
The root file write7
Part 5 · Errors
Quiet the noise8
Part 6 · Timing and truth
The lying log9
Part 7 · The long view
Teaching tee10

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.

Tee companion · No. 01
the name

The T fitting

the fitting tee is named for

the plumbing fitting, and one differencethe whole stream incopy onecopy twoeach arm gets the whole streamthe name derives from thetee pipe fitting; but thecommand duplicates the inputinto each output instead ofdividing it into portionsfirst released 1974the fitting splits a flow; the command duplicates it: whole stream, every arm

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.

ONE HONEST HOUR

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.

Tee companion · No. 02
the flag

Append with -a

the flag that keeps the past

one flag, and the past survives$ printf "first line" | tee log.txtfirst line$ printf "second line" | tee -a log.txtsecond lineboth kept, in orderlog.txtfirst linesecond line-a appendscreated if missing-a: append rather than overwrite, and the file is created if not there

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.

ONE HONEST HOUR

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.

Tee companion · No. 03
the copies

Many files at once

one stream, every file listed

one stream, three files, one pass$ printf "one stream" | tee a.txt b.txt c.txtone streamprinted once on screen, and:a.txtb.txtc.txt$ cat a.txt b.txt c.txtone streamone streamone streamduplicated to each outputfile...: one or more names to receive the command input data

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.

ONE HONEST HOUR

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.

Tee companion · No. 04
the root write

The root file write

sudo tee -a, decoded piece

the article's one-liner, decodedSIMULATIONno sudo invoked; scratch file stands inprintf "key line" | tee -a rootkeys.sim > /dev/null1stream rides the pipe2tee -a appends3the null sink hushesthe real article line, over ssh:sudo tee -a/root/.ssh/authorized_keys2> /dev/nullappend with tee -a inside sudo, hush the echo with the null sink

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.

ONE HONEST HOUR

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.

Tee companion · No. 05
the hush

Quiet the noise

2> /dev/null, on purpose

silence on purpose, never by accident$ ls nosuchfile 2> /dev/null | tee quiet.lognot one character on screenquiet.log came back emptythe good stream, logged clean/dev/nullstderr, fd 2, aimed herethe pipeline's errors are notpassed on through the pipe;quiet.log2> /dev/null aims the error stream at the sink before the log

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.

ONE HONEST HOUR

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.

Tee companion · No. 06
the lie

The lying log

a partial log is not the truth

read too early, the log liesmid-runthe log holds half the storyand the pipeline has notfinished writing yetthe screen already showed:firstsecondthe log, read mid-run:firststderr unbuffered, stdout line-buffered: later text may arrive earlier

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.

ONE HONEST HOUR

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.

Tee companion · No. 07
pass it on

Teaching tee

one honest hour, one friend

five lines, one hour, one friend1printf "hello tee" | tee hello.txt2the trap: only second run kept3tee -a: both lines kept4tee mid.txt | grep am: gamma5substitution: 6 and 3when they can explain why thetrap lost the first line,the hour is donethey type, you read aloud,one honest hour, per the planpass the junction on: the last stream of the book is a friend

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.

ONE HONEST HOUR

Sit with one friend and teach tee in one sitting; they type the five lines, you read each answer aloud.

Index

Index


Append with -a5
Many files at once6
Quiet the noise8
Teaching tee10
The lying log9
The root file write7
The T fitting4