$ CLI Academy

Power Tools

Redirects & Append

Send output to files instead of the screen.

> overwrites a file with stdout: echo "todo" > tasks.txt.

>> appends without wiping existing content.

2> redirects errors. &> catches both stdout and stderr (bash/zsh).

$ Commands to try

$ echo "hello" > out.txt
$ echo "more" >> out.txt
$ ls /nope 2> errors.txt
$ command &> all.log

Practice exercise

Write your name to out.txt, append a second line, then cat the result.