bash

[转] All about redirection

Copy from: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html

3.1 Theory and quick reference

There are 3 file descriptors, stdin, stdout and stderr (std=standard).

Basically you can:

  • redirect stdout to a file
  • redirect stderr to a file
  • redirect stdout to a stderr
  • redirect stderr to a stdout
  • redirect stderr and stdout to a file
  • redirect stderr and stdout to stdout
  • redirect stderr and stdout to stderr

1 ‘represents’ stdout and 2 stderr.

A little note for seeing this things: with the less command you can view both stdout (which will remain on the buffer) and the stderr that will… 查看详细