“|"是什么意思?在终端命令行中是什么意思? [英] What does "|" mean in a terminal command line?

查看:35
本文介绍了“|"是什么意思?在终端命令行中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉在这里发布它,但 Google 在搜索符号时做得很糟糕.

|"是什么意思意思是:

一些字符串" |一些可执行文件

解决方案

是管道符号.它在命令行上分隔两个程序(参见 Pipelinesbash 手册中),第一个程序的标准输出(在管道的左侧)连接到第二个程序的标准输入(在管道的右侧).

例如:

谁 |wc -l

为您提供连接到您的计算机的人数或会话数(加上来自 who 的标题行的 1).打折标题行:

谁 |sed 1d |wc -l

sed的输入来自whosed的输出到wc.

底层系统调用是pipe(2)使用结合 fork(), dup2()exec*() 系统调用.

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

解决方案

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.

这篇关于“|"是什么意思?在终端命令行中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆