Contents


Preamble


Background

When redirecting the output of a command to a file or piping it to another command, you might notice that the error messages are printed on the screen.

In Bash and other Linux shells, when a program is executed, it uses three standard I/O streams. Each stream is represented by a numeric file descriptor:

A file descriptor is just a number representing an open file.

The input stream provides information to the program, generally by typing in the keyboard.

The program output goes to the standard input stream and the error messages goes to the standard error stream. By default, both input and error streams are printed on the screen.

Redirecting

Output