Redirect
One, interactive hardware equipment
- Standard input: accept user input data from the device
- Standard output: publish book data to users through this device
- Standard error: Brave the device reports execution error information
Types of | Device file | File description number | Default device |
---|---|---|---|
Standard input | /dev/stdin | 0 | keyboard |
Standard output | /dev/stdout | 1 | monitor |
Standard error output | /dev/stderr | 2 | monitor |
Two, redirect operation
Types of | Operator | use |
---|---|---|
Redirect input | < | Read data from the specified file |
Redirect output | > | Save the standard output result to the specified file and overwrite the original content |
Redirect output | >> | Append the standard output result to the end of the specified file without overwriting the original content |
Standard error output | 2> | Save the error information to the specified file and overwrite the original content |
Standard error output | 2>> | Append the error message to the end of the specified file without overwriting the original content |
Mixed output | &> | Save standard output and standard error to the same file |
Mixed output | 2>&1 | Redirect standard error output to standard output |
Example:
3. Pipeline operation conforms to "|"
Simply put, the pipe operator is "| "The result on the left is inherited by the" | "right, and multiple pipes can be used in the same line of command.
Example: Use of
pipe symbol with xargs:
The xargs command can accept a string through a pipe, and divide the received string into many parameters through spaces, and then pass the parameters to the subsequent commands for execution
Example: