↑↓ move Enter open Esc close

Redirection (> and >>)

Sending a program's streams to files instead of the screen.

Redirection is the shell pointing a stream at a file. > writes, replacing the file's contents, and it truncates the target before the command even runs, which is why redirecting a file onto itself destroys it. >> appends, preserving what is there. 2> captures errors, and < feeds a file as input.

The distinction between > and >> is the most consequential pair of characters in the shell: one accumulates, the other overwrites.

See it in practice

$ echo "first" > log.txt && echo "second" >> log.txt && cat log.txt

The first arrow replaces, the second appends. Swapping them silently destroys data: the most consequential two characters in the shell.

Where you'll meet it

Learn these concepts by typing them: the interactive course builds them up lesson by lesson in a real simulated shell.