"|"代表什么?在终端命令行中是什么意思? [英] What does "|" mean in a terminal command line?
问题描述
很抱歉在此处发布它,但是Google在搜索符号时做得非常糟糕.
Sorry for posting it here, but Google does a very bad job when searching for symbols.
"|"是什么意思是:
"some string" | someexecutable.py
推荐答案
它是管道符号.它在命令行上将两个程序分开(请参见bash
中的 Pipelines
手册),第一个程序的标准输出(在管道的LHS上)连接到第二个程序的标准输入(在管道的RHS上).
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).
例如:
who | wc -l
为您提供连接到计算机的人数或会话数(为who
中的标题行加上一个).要打折标题行:
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
sed
的输入来自who
,而sed
的输出进入wc
.
The input to sed
comes from who
, and the output of sed
goes to wc
.
底层系统调用是 pipe(2)
与 dup2()
和 exec*()
系统调用.
The underlying system call is pipe(2)
used in conjunction with fork()
, dup2()
and the exec*()
system calls.
这篇关于"|"代表什么?在终端命令行中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!