First, knowledge:
Redirect: redirect input and output redirection points;
Redirect standard input (STDIN, file descriptor 0): Default input from the keyboard, may also be input from another file or command.
Redirect standard output (STDOUT, file descriptor 1): The default output to the screen.
Redirect the error output (STDERR, file descriptor 2): The default output to the screen.
- Command <file: the file as a command of standard input
- << command delimiter: reads from the standard input, until stopped met delimiter
-
Command <Document 1> File 2: 1 as a command file standard input and standard output to the file 2
- Command> redirect standard output file to a file (original file data is empty)
- Command 2> file error output is redirected to a file (original file data is empty)
- Command >> file redirect standard output to a file (appended to the original content)
- 2 command >> file error output redirected to a file (appended to the original content)
- File command >> 2> & 1 (or command file >> &): standard error output together with the output written to the file (appended to the original content)
Output redirection operators: original output commands to the information screen, which is output to a file, sub-type cover (> Clear the original content) and the additional type (>>) thereof.
Or whether errors are denoted output file: & >> or 2> & 1
Examples: wc -l </ etc / passwd
vim editor: