What does “|” mean in a terminal command line? [closed]

眉间皱痕 提交于 2019-12-29 05:01:09

问题


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

回答1:


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).

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.

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




回答2:


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




回答3:


| 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



来源:https://stackoverflow.com/questions/12400371/what-does-mean-in-a-terminal-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!