管道和重定向 [英] Piping and Redirection

查看:205
本文介绍了管道和重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是管道和重定向之间准确的区别?

What is exact difference between Piping and Redirection ?

我们应该在哪里使用的管道,我们应该在哪里使用重定向?

Where should we use piping and where should we use redirection ?

他们是如何工作的内部?

How they internally work ?

推荐答案

重定向是(大部分)的文件(从文件重定向流/)。

Redirection is (mostly) for files (you redirect streams to/from files).

管道是过程:你管(重定向)从一个进程流到另一个。

Piping is for processes: you pipe (redirect) streams from one process to another.

实际上你真正做的是连接的一个标准流(通常为标准输出)一个进程到另一个进程(标准流通常标准输入),通过管道。

Essentially what you really do is "connect" one standard stream (usually stdout) of one process to standard stream of another process (usually stdin) via pipe.

管道也有在同步副作用:他们阻止一个进程(在读)时,对方已经没什么可写的(还),或在阅读过程中不能读足够快(当管道缓冲区已满)。

Pipes have also the synchronization "side effect" : they block one process (on reading) when the other has nothing to write (yet) or when reading process cannot read fast enough (when the pipe's buffer is full).

这篇关于管道和重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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