什么是管道中的BASH是如何工作的一个简单的解释?

编程入门 行业动态 更新时间:2024-10-11 01:19:31
本文介绍了什么是管道中的BASH是如何工作的一个简单的解释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我经常使用的bash管道,例如:

I often use pipes in BASH, e.g.:

dmesg | less

虽然我知道这是什么输出,需要的dmesg ,让我通过它滚动与少,我做的不明白什么 | 在做什么。难道仅仅&GT相反;

Although I know what this outputs, it takes dmesg and lets me scroll through it with less, I do not understand what the | is doing. Is it simply the opposite of >?

  • 是否有一个简单的,或隐喻解释是什么 | 确实
  • 当几个管道在一行上使用善有善报?
  • 是无处不在它出现在一个bash脚本管一致的行为?
推荐答案

UNIX管道连接STDOUT(标准输出)的第一道工序到第二的STDIN(标准输入)的文件描述符。会发生什么然后是,当第一个进程写入其STDOUT,该输出可以立即(从STDIN)由第二过程读出。

A Unix pipe connects the STDOUT (standard output) file descriptor of the first process to the STDIN (standard input) of the second. What happens then is that when the first process writes to its STDOUT, that output can be immediately read (from STDIN) by the second process.

使用多个管道没有比使用单管不同。每根管子是独立的,并简单地连接相邻进程的STDOUT和STDIN。

Using multiple pipes is no different than using a single pipe. Each pipe is independent, and simply links the STDOUT and STDIN of the adjacent processes.

您的第三个问题是有点含糊不清。是的,管道,因为这样,到处都是一致的bash脚本。然而,管道符 | 可以重新present不同的事情。双管( || ),再presents的或运算符,例如

Your third question is a little bit ambiguous. Yes, pipes, as such, are consistent everywhere in a bash script. However, the pipe character | can represent different things. Double pipe (||), represents the "or" operator, for example.

更多推荐

什么是管道中的BASH是如何工作的一个简单的解释?

本文发布于:2023-11-10 07:11:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:道中   简单   工作   BASH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!