Basic

Two streams, one meaning each

The answer and the complaint are not the same stream. The split is why a pipe gets the answer and a person reads the complaint.

What you will see

answer clean. Never is the claim.

About 1 min of reading

Try It

Keep the streams apart

1

Write the answer shape

printf 'file\tcount\n' > /tmp/o.txt; wc -f -w < /tmp/o.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
2. Two fields is one shape, which is machine shaped.
2

Write a complaint

printf 'a.txt line 4 unread: no newline\n' > /dev/stderr; wc -c < /dev/null

Before you run it, say out loud what it will print. Then open the answer.

What it prints
0. The complaint went to the other stream, which is the split.
3

Prove the answer is clean

printf '42\n' | grep -c -v -f '[a-z]' /dev/stdin | awk '{print ($1==0) ? "answer clean" : "complaint in answer"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
answer clean. Never is the claim.

Data Flow

A run to two streams
1 The answer is written in one shape
↓
2 The complaint is written with names
↓
3 The two streams are kept apart
↓
4 The answer never carries a complaint
Why this works
Why the shape of the answer is one

One shape is a shape a reader writes down. A shape that changes per run is a shape nobody reads.

The one thing never written to the answer

A word that is only for a person. A person word in the answer is a shape that breaks a pipe.

Examples

The answer is machine shaped

One shape for every answer. One shape is what makes a later command read it without a person.

The complaint is for a person

The complaint names the file and the line. Names are for a person, and a person is not a pipe.

The answer never carries a complaint

Never. A complaint in the answer is a shape that a later command reads as data.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Reading input as a pipe or a name
Previous Lesson
Reading input as a pipe or a name
Next Lesson
Exit codes as a written set
Exit codes as a written set →