>_How the Terminal Works · Lesson 3 of 7
stdin, stdout & Pipes
Every program is born holding three data streams: input, output, errors. Redirection and pipes just re-plug those streams — into files, or into other programs. This is the terminal's superpower.
The pipe | connects one program's stdout to the next one's stdin, no temp files involved. Both programs run simultaneously; the kernel shuttles bytes between them and pauses the fast one when the slow one falls behind. Small tools, each doing one job, snapped together like hose segments — the Unix philosophy in one character.
◆ Note
Programs adapt to where their output goes: ls prints columns to a terminal but one-name-per-line into a pipe (it checks 'is stdout a TTY?'). Same reason color codes vanish when you redirect to a file — well-behaved tools only emit them for real terminals.
Programs adapt to where their output goes: ls prints columns to a terminal but one-name-per-line into a pipe (it checks 'is stdout a TTY?'). Same reason color codes vanish when you redirect to a file — well-behaved tools only emit them for real terminals.