Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Redirection?

Definition 8.5 University Computer Science — Year 1 · Capítulo 8 — The Shell

A redirection connects a standard stream of a command to a file: > f sends standard output to f, emptied first; >> f appends to it; < f reads standard input from it; 2> f sends standard error; and 2>&1 sends standard error wherever standard output goes at that point of the line. Redirections are performed by the shell before the program starts, from left to right.

Standard output (1) and standard error (2) of ls. With > all.txt alone, the error still reaches the terminal; 2>&1, written after it, sends the error where the output goes now, to the file. Written before > all.txt, it would copy the old destination, the terminal ().
Standard output (1) and standard error (2) of ls. With > all.txt alone, the error still reaches the terminal; 2>&1, written after it, sends the error where the output goes now, to the file. Written before > all.txt, it would copy the old destination, the terminal (Exercise 8.6).
Ler no capítulo →