Glossary
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
Print text and variables, and write or append to files with > and >>.
teeSplit a stream: watch output live while saving a copy — and write files with sudo.
stdout (standard output)Stream 1 — where a program writes its normal results.
Pipes & redirectionIn-depth guide