redirection

Sending a command's output into a file instead of the terminal: > replaces the file, >> appends to the end of it.

In more detail

> replaces the file and >> appends to it. 2>&1 sends error output to the same place as normal output, and >&2 sends a message to standard error. Appending has no memory of what the file already holds, so running the same line twice leaves two copies.

Examples

echo "listen 8080" >> by-hand/server.conf appends a second copy on a second run; the lineinfile module adds the line only if it is missing.
noisy > out.txt 2> err.txt
cmd >> log 2>&1
printf 'service.env\n' > .gitignore

Related terms

Taught in

References