Input/Output Redirection (>, >>, <)
Master redirecting command output to files and using files as input for commands, enhancing script flexibility.
What is I/O Redirection?
In Linux, commands often produce output or require input. Input/Output (I/O) redirection lets you change where a command gets its input from or sends its output to.
Instead of just seeing output on your screen (the terminal), you can save it to a file, or even feed a file's content directly into another command.
Understanding Standard Streams
Every Linux command interacts with three "standard" data streams:
- Standard Input (STDIN): Where a command expects to receive input (usually your keyboard).
- Standard Output (STDOUT): Where a command sends its normal output (usually your screen).
- Standard Error (STDERR): Where a command sends error messages (also usually your screen).
Redirection allows us to change these default destinations or sources.
All lessons in this course
- Managing Processes (ps, top, kill)
- Input/Output Redirection (>, >>, <)
- Piping Commands (|)
- Background Jobs & Job Control