File descriptor
- STDIN: standard input, receive input from mouse, keyboard or other input device, file descriptor is 1
- Stduot: Output All normal output results, file descriptor is 2
- STDERR: Output All error messages, file descriptor is 3
Redirection character
- ">": Using the method, "command > File", after the process accepts the standard input, the redirect causes the standard output to change direction, not output to the screen, but output to a file. The standard error output remains unchanged, and the default output is to the screen or to the appropriate device. In addition, if the file already exists, the original content will be erased. For example:
- ">>": similar to the one above, except that when the file is written, the contents of the file are not purged but appended later. The file is created when the destination file does not exist.
- ">&": the redirect for all standard outputs. To output the error message to a file, use the >& redirect. This command will also erase the original content when writing to the file.
- ">>&": similar to the previous one, just write the file in Append mode
- "<": "Command < file", the process will get input information from the file, rather than input from the screen.
- "<<": one of the redirection characters followed by a delimiter. For example:
- "Command%n%c file": Command output redirected commands,%n file descriptor, default value is 1,%c redirect, file destination.
- Examples of several complex redirects:
- REDIRECT standard error to standard input command 2>&1
- The first file as standard input and as standard output command <> file
- Use the file descriptor x as the standard input command <&x
- redirect standard output to file descriptor x command >&m
- Turn off standard output command 1>&-
- Turn off standard error output command 2>&-
- Turn off standard input command 0<&-
Shell commands (2)--file descriptors and redirection characters