Skip to main content
LESSON 3 of 5//Stream Processing

Redirecting output with > and >>

Redirection lets you send command output to a file instead of the screen. > overwrites the file, while >> appends to it.

Output redirectionzsh // interactive
# Write output to a file (overwrites)
~echo 'Hello' > greeting.txt
# Append to a file
~echo 'World' >> greeting.txt
~cat greeting.txt
Hello
World
# Redirect stderr to a file
~npm install 2> errors.log
# Redirect both stdout and stderr
~npm run build > build.log 2>&1
PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: