redirection
also: input/output redirection, I/O redirection, stream redirection
Redirection is the process of sending the input or output of a command to a file or another command instead of the terminal. It uses operators like >, >>, <, and | to change where data flows.
In Linux, programs typically read from standard input (stdin) and write to standard output (stdout). Redirection allows you to change these destinations without modifying the program itself.
Common redirection operators include: > (overwrite a file), >> (append to a file), < (read from a file), and | (pipe output to another command). For example, ls > files.txt saves a directory listing to a file, while grep "error" < logfile.txt reads input from a file.
You can also redirect error messages using 2> (standard error), combine streams with 2>&1, and redirect to /dev/null to discard output entirely. Redirection is fundamental to shell scripting and command chaining.