Linux Command Line - I/O Redirection

2017-06-13
linuxcommand line

Streams

  • 0, stdin is standard input.
  • 1, stdout is standard output.
  • 2, stderr is standard error.

Standard Input

Transmitted through the keyboard, from the user to a program. It is terminated when the end of file (EOF) is reached.

Standard Output

Display data generated by a program on the terminal if it is not redirected.

Standard Error

Display errors generated by a program on the terminal if it is not redirected.

Overwrite Target

  • >, 1> standard output.
  • < standard input.
  • 2> standard error.
  • &> standard output and standard error.
  • i>&j redirect anything that targets i to j.
  • 2>&1 standard error to standard output

Append Target

  • >>, 1>> standard output.
  • << standard input.
  • 2>> standard error.

Pipes

Redirect streams from one program to another.

Filters

Alter piped redirection and output: find, grep, tee, tr, wc.

/dev/null special file that trashes any data that it receives. You can redirect output that you do not want displayed or passed to another program.