LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is program output redirection and what are common use cases?

Redirection rewires a stream away from its default — sending output to a file (or /dev/null) instead of the screen, or taking input from a file instead of the keyboard.

Because stdin/stdout/stderr are just streams the shell sets up before launching a command, the shell can point them somewhere else first. The program is none the wiser — it still "writes to FD 1", but FD 1 now lands in a file.

FD Stream Default Can be redirected to
0 stdin keyboard a file (< file)
1 stdout console a file, /dev/null, a pipe
2 stderr console a file, /dev/null, FD 1

Common reasons to redirect:

  • Save output for later: command > results.txt
  • Discard noise: command 2> /dev/null throws away error spam
  • Feed a script its input: mysql < dump.sql

Key idea: the command doesn't change — only where its streams are connected does. That separation is what makes the same tool reusable in a hundred different pipelines.

From Quiz: LIOS / Reading and Editing Files from the Command Line | Updated: Jul 14, 2026