Home  >  Article  >  Operation and Maintenance  >  What does vertical bar mean in linux

What does vertical bar mean in linux

WBOY
WBOYOriginal
2022-03-11 16:07:247788browse

In Linux, the vertical bar means the pipe symbol. The function of this symbol is to connect two commands and use the output of the first command as the input of the second command. The syntax is "command 1 | command 2".

What does vertical bar mean in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What does the vertical bar mean in Linux

The vertical bar '|' is used as a pipe character in Linux, and the output of the command before '|' is used as the input after '|'.

Its function is:

Connect two commands and use the output of the first command as the input of the second command.

 command 1 | command 2

The example is as follows:

$ls -s|sort -nr

-s is file size, -n is numeric-sort, -r is reverse, reverse

This command lists the documents (including size) in the current directory and sends the output to sort command as input, the sort command sorts the output of ls in numerically descending order.

$ls -s|sort -n

Output in order from small to large.

Of course, multiple operations can be performed. For example, the following function is to first remove pure numbers, then use sed to replace vertical bars (not pipe symbols here) with spaces, then take out the results, sort them, and then process the results. The selection display

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What does vertical bar mean in linux. 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