Why is STDERR redirected to STDOUT

I noticed that we have basically 3 file streams. These are STDIN, STDOUT and STDERR .. My question is: why is STDERR redirected to STDOUT?

+7
source share
3 answers

stderr not redirected to stdout . By default, both streams are connected to the same device (current screen or terminal).

You can redirect them to different files:

 $ command > stdout.log 2> stderr.log 

To really redirect stderr to stdout , you must specify:

 $ command 2>&1 
+35
source

This is not true; it just happens that both stdout and stderr are usually mapped to the same output stream (usually the console). If you redirect stdout to a file, for example, you will find that stderr remains directed to the console.

The important point is that they are independently redirected.

+5
source

Like stdout , stderr usually directed to the output device of the standard console (usually on the screen). This means that stderr not redirected to stdout , but they have a common file descriptor. You can redirect stderr to some other destination from the program using the freopen function.

0
source

All Articles