thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Systems & Data Center · Foundational

Redirection

Shell syntax that sends a command's input or output to or from files instead of the terminal.

Definition

> overwrites a file with stdout, >> appends, < reads stdin from a file, 2> redirects stderr, and 2>&1 sends stderr to the same place as stdout. &> redirects both in Bash.

Example

./backup.sh >> /var/log/backup.log 2>&1 appends all output to a log.

Exam tip

Order matters: > file 2>&1 captures both, while 2>&1 > file leaves stderr on the terminal.

Related terms