Article directory
提示:以下是本篇文章正文内容,下面案例可供参考
1. What is redirection?
- "Redirection" is to re-change the direction of command input and output.
- The original input direction of the command is the keyboard, so this input is called standard input.
- The original output direction of the command is the display, so this output is called standard output.
2. Redirect command
1. Redirect output command
Command format:
a command with output results > file name
Function description:
- Direct the output of this command to a file.
- The command must have an output before it can be placed before ">".
Demo:
2. Redirect input command
Command format:
a command that needs to input data from the keyboard < file name
Function description:
- If the command needs to get one or some input data from the keyboard during execution, you can use "<" to redirect its standard input so that the input data it needs comes from a file instead of the keyboard.
Demo:
- Use the mail command to send mail to other users in the Linux system.
Use the file to improve:
3. Other commands
- "<" can be used or not
- Mixed use of redirects
instant tune
重定向混合使用需要注意的问题:
- Usage of "-"
3. Pipeline commands
Command format:
Command 1 | Command 2 | Command 3·····
Function description:
- Pass the output result of the previous command through the pipeline command "|" as the input data of the next command.
- Both sides of the pipeline command can only be commands, not files.
Function Demo:
Notes: