Vous êtes sur la page 1sur 1

2.14.

1 Standard Error
Occasionally, you may redirect standard output but find that the program still prints
something to the terminal.
This is called standard error (stderr); its an additional output stream for diagnostics
and debugging. For
example, this command produces an error:
$ ls /fffffffff > f
After completion, f should be empty, but you still see the following error message on
the terminal as standard
error:
ls: cannot access /fffffffff: No such file or directory
You can redirect the standard error if you like. For example, to send standard output
to f and standard error to
e, use the 2> syntax, like this:
$ ls /fffffffff > f 2> e
The number 2 specifies the stream ID that the shell modifies. Stream ID 1 is standard
output (the default), and
2 is standard error.
You can also send the standard error to the same place as stdout with the >& notation.
For example, to send
both standard output and standard error to the file named f, try this command:
$ ls /fffffffff > f 2>&1

Vous aimerez peut-être aussi