stdin, stdout and stderr
Bash creates stdin, stdout and stderr streams for each command in the terminal. These streams carry text as data.
In Linux, almost all the streams are treated as if they were files. Just like you can read/write a file, you can read/write a data from these streams.
stdin: Stands for standard input. It takes text as input.
stdout: Stands for standard output. The text output of a command is stored in the stdout stream.
stderr: Stands for standard error. Whenever a command faces an error, the error message is stored in this stream.
Each stream has file descriptor ID as below
- stdin – /dev/stdin or /dev/fd/0
- stdout – /dev/stdout or /dev/fd/1
- stderr – /dev/stderr or /dev/fd/2