How to see from which file descriptor output is coming?
$ echo hello hello $ echo hello 1>&2 hello
all are going to /dev/pts/0
but there are 3 file descriptors 0,1,2
linuxoutputshellstderrstdout
How to see from which file descriptor output is coming?
$ echo hello hello $ echo hello 1>&2 hello
all are going to /dev/pts/0
but there are 3 file descriptors 0,1,2
Best Answer
Ordinary output happens on file descriptor 1 (standard output). Diagnostic output, as well as user interaction (prompts etc.), happens on file descriptor 2 (standard error), and input comes into the program on file descriptor 0 (standard input).
Example of output on standard output/error:
In both instances above,
echo
writes to standard output, but in the second command, the standard output of the command is redirected to standard error.Example of filtering (removing) one or the other (or both) of the channels of output:
The output streams are connected to the current terminal (
/dev/pts/0
in your case), unless redirected elsewhere as shown above.