DELAPARRA
Index
Color
NL
Category: CLI commands

> and >>

Explained by Updated

What is > and >>?

> and >>: Redirect output — > overwrites a file with output. >> appends to a file. The > and >> operators send a command's output to a file instead of the screen. echo hello > notes.txt creates the file or overwrites it. echo world >> notes.txt adds a line to the end.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about > and >>

How is > and >> used in practice?

The difference is easy to forget and costly to get wrong. A single > on an existing log or config file wipes its contents before the command even runs. Many shells offer set -o noclobber to stop > from overwriting files by accident.

What should you keep in mind with > and >>?

These operators only capture normal output. Error messages go to a separate stream, so command > out.txt still prints errors to the screen. Use 2> for errors, or > out.txt 2>&1 to send both to the same file. In cron jobs, redirecting both is the easiest way to find out later why a job failed at three in the morning.

At a glance

CategoryCLI commands
Explained by
Updated

More CLI commands terms

All terms starting with a number or symbol

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.