Learn › Linux Foundations
I/O Redirection
Control where input comes from and where output goes. Redirect stdout, stderr, and stdin to files. Connect commands with pipes. Combine redirects for precise control over data flow.
Labs in this module
- File Descriptors: The Three Channels - Every command has three numbered channels: stdin (0), stdout (1), stderr (2). Watch the wiring in a live flow diagram, prove the two output
- Append with >> - The single erases a file every time it writes. The double appends: it adds new lines to the end and never touches what is above. Build a thr
- Merge Streams with 2>&1 - Fold the error channel into stdout with 2&1. Merge both streams of a report into one file, learn why the order of redirections matters, then
- Redirect All: &> - One operator to capture everything a command says. Watch a plain let the stderr line escape to the screen, catch both channels in one file w
- Combining Redirects: Aim Every Stream - The module's final move: stack the operators you already own. Split a command's results and errors into two files with one line, merge both
- Split the Stream with tee - End the see-it-or-save-it trade. Watch a line land on screen and in a file at once with tee, snapshot a pipeline mid-flight without disturbi
- Pipe Chains: Build a Pipeline - Chain two or more pipes into a pipeline: sort and dedupe a stream, pull the largest value with a numeric sort, tally repeats with uniq -c, a
- The Pipe: Feed One Command into Another - Meet the pipe: the operator wires one command's stdout into the next command's stdin, no file in between. Count lines, trim a stream, and tr
- The Null Device: /dev/null - Meet /dev/null, the null device that destroys everything written to it. Shred a command's errors with 2/dev/null, keep only the errors with
- The > Operator: Redirect Output to a File - Meet the operator: point a command's stdout at a file instead of the screen. Write a file with one command, verify it with cat, discover tha
- Input Redirection - Feed a file into a command's stdin with the < operator. The shell opens the file, the command reads a nameless stream, and the output proves
- Catch Errors with 2> - Steer the error channel. Prove errors ride channel 2 by watching one line refuse to leave the screen, then catch complaints in a file with 2
- Operation Signal - The I/O Redirection module capstone mission. Drill , , <, 2, /dev/null, 2&1, &, pipes, pipe chains, tee, and combining redirects in one hand