“|”在终端命令行中的含义是什么?

时间:2022-09-06 14:30:40

Sorry for posting it here, but Google does a very bad job when searching for symbols.

很抱歉在此处发布,但Google在搜索符号时做得非常糟糕。

What does the "|" mean in:

什么是“|”意思是:

"some string" | someexecutable.py

3 个解决方案

#1


20  

It is the pipe symbol. It separates two programs on a command line (see Pipelines in the bash manual), and the standard output of the first program (on the LHS of the pipe) is connected to the standard input of the second program (on the RHS of the pipe).

它是管道符号。它在命令行上分离两个程序(参见bash手册中的管道),第一个程序的标准输出(在管道的LHS上)连接到第二个程序的标准输入(在管道的RHS上) )。

For example:

例如:

who | wc -l

gives you a count of the number of people or sessions connected to your computer (plus one for the header line from who). To discount the header line:

为您计算连接到计算机的人数或会话数(加上一个用于标题行的人员)。要折扣标题行:

who | sed 1d | wc -l

The input to sed comes from who, and the output of sed goes to wc.

sed的输入来自who,sed的输出转到wc。

The underlying system call is pipe(2) used in conjunction with fork(), dup2() and the exec*() system calls.

底层系统调用是pipe(2)与fork(),dup2()和exec *()系统调用一起使用。

#2


7  

It's called pipe. It gives the stdout of the first command ("some string") as the stdin to the second command (someexecutable.py).

它被称为管道。它将第一个命令(“some string”)的stdout作为第二个命令的stdin(someexecutable.py)。

#3


4  

| is a pipe. It sends output of one command as input of the next. It is explained here http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-103-4/#3-pipes

|是一个管道。它发送一个命令的输出作为下一个命令的输入。这里解释了http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-103-4/#3-pipes

#1


20  

It is the pipe symbol. It separates two programs on a command line (see Pipelines in the bash manual), and the standard output of the first program (on the LHS of the pipe) is connected to the standard input of the second program (on the RHS of the pipe).

它是管道符号。它在命令行上分离两个程序(参见bash手册中的管道),第一个程序的标准输出(在管道的LHS上)连接到第二个程序的标准输入(在管道的RHS上) )。

For example:

例如:

who | wc -l

gives you a count of the number of people or sessions connected to your computer (plus one for the header line from who). To discount the header line:

为您计算连接到计算机的人数或会话数(加上一个用于标题行的人员)。要折扣标题行:

who | sed 1d | wc -l

The input to sed comes from who, and the output of sed goes to wc.

sed的输入来自who,sed的输出转到wc。

The underlying system call is pipe(2) used in conjunction with fork(), dup2() and the exec*() system calls.

底层系统调用是pipe(2)与fork(),dup2()和exec *()系统调用一起使用。

#2


7  

It's called pipe. It gives the stdout of the first command ("some string") as the stdin to the second command (someexecutable.py).

它被称为管道。它将第一个命令(“some string”)的stdout作为第二个命令的stdin(someexecutable.py)。

#3


4  

| is a pipe. It sends output of one command as input of the next. It is explained here http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-103-4/#3-pipes

|是一个管道。它发送一个命令的输出作为下一个命令的输入。这里解释了http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-103-4/#3-pipes