stdout, stdin, stderror and more about redirection
There are three standar I/O streams:
stdin (Standard Input) → stream for input usually from the keyboard
stdout (Standard Output) → stream for output usually to the terminal
stderr (Standard Error) → stream for errors usually to the terminal
The previous streams are represented by file descriptors
stdin → 0, stdout → 1, stderr → 2
It redirects the output of echo command to the file output.txt
Linux has some operators that redirect the stdin, stdout and stderr streams
→ redirects the stdout to a file, and overwrites it
→ redirects the stdout to a file but it appends it
→ redirects stdin from a file
2 → redirects stderr to a file
& → redirects both stdout and stderr to a file
It redirects the stdout of echo command to output.txt but it appends it
redirect stdin from a file to sort command
redirect stdout to the file error.txt
redirect stdout and stdout to different files
redirect stdout and stderr to the same file
not show an output at all by redirecting stdout to /dev/null
not show any error by redirecting stderr to /dev/null
/dev/null is a special file that accepts input and does nothing with it
#linux #shell #cli #konsole #ubuntu #fedora #opensuse
My Gaming channel
/ @thunderforgewt