Home>Article>Operation and Maintenance> What is the Linux pipe command?

What is the Linux pipe command?

Guanhui
Guanhui Original
2020-06-28 15:14:53 8333browse

The Linux pipeline command is "|", which is used to connect multiple instructions. The output stream of the previous instruction will be used as the operation object of the subsequent instruction. The command format is "Instruction 1 | Instruction 2 | ...", the following instruction of this command must be able to receive the standard input stream command before it can be executed.

What is the Linux pipe command?

Pipeline command is used to connect multiple instructions. The output flow direction of the previous instruction will be used as the operation object of the subsequent instruction.

The operator of the pipeline command is: "|", which can only process the correct output information sent by the previous instruction, and has no direct processing ability for error information. Then, it is passed to the next instruction as the operation object.

Basic format:

指令1 | 指令2 | …

[Command 1] is correctly output as the input of [Command 2], and then the output of [Command 2] is used as the input of [Command 3]. If [Command 3] 】There is output, then the output will be displayed directly on the screen. The correct output of [Command 1] and [Command 2] after passing through the pipeline is not displayed on the screen.

[Reminder]:

The pipeline command can only process the correct output of the previous instruction, but cannot handle the error output;

The following instruction of the pipeline command must be able to receive Standard input stream commands can be executed.

Usage example

1. Display detailed information of the contents of the /etc directory in pages

$ ls -l /etc | more

2. Input a string into a file

$ echo "Hello World" | cat > hello.txt

Recommended tutorials: "PHP" "Linux Operation and Maintenance"

The above is the detailed content of What is the Linux pipe command?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn