Linux “|”是什么意思 在终端命令行中是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12400371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does "|" mean in a terminal command line?
提问by frazman
Sorry for posting it here, but Google does a very bad job when searching for symbols.
很抱歉在这里发布它,但谷歌在搜索符号时做得非常糟糕。
What does the "|" mean in:
“|”是什么意思 意思是:
"some string" | someexecutable.py
采纳答案by Jonathan Leffler
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).
它是管道符号。其分离的命令行(见关于两个节目Pipelines
中bash
手册),并且所述第一程序的标准输出(在管的左轴)被连接到第二程序的标准输入(在管的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:
为您提供连接到您的计算机的人数或会话数(加上 1 的标题行who
)。要打折标题行:
who | sed 1d | wc -l
The input to sed
comes from who
, and the output of sed
goes to wc
.
to 的输入sed
来自who
,而 的输出sed
去wc
。
The underlying system call is pipe(2)
used in conjunction with fork()
, dup2()
and the exec*()
system calls.
回答by P.P
回答by mehulved
| 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