File Descriptor Image

Shell Process File Descriptors SHELL PROCESS FD 0: stdin FD 1: stdout FD 2: stderr Keyboard (Terminal) File < input.txt Pipe cmd1 | cmd2 Terminal Display File > output.txt Next Cmd cmd1 | cmd2 Terminal (Errors) Error File 2> errors.txt /dev/null 2> /dev/null FD 0 FD 1 FD 2 Common Redirection Examples: echo "hello" > file.txt # stdout to file ls /bad 2> errors.txt # stderr to file sort < input.txt # stdin from file cmd 2> /dev/null # discard errors File Descriptor Numbers: 0 = stdin (input) 1 = stdout (normal output) 2 = stderr (error output) Always available in every process
Backlinks