sed是否阻止? [英] Is sed blocking?

查看:122
本文介绍了sed是否阻止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对sed的印象没有任何阻挠,因为当我说时:

I had the impression sed wasn't blocking, because when I do say:

iostat | sed

sed在数据到达时对其进行处理,但是当我这样做时

sed processes the data as it arrives, but when I do

iostat | sed | netcat

然后sed阻止netcat.

我说得对吗?

推荐答案

sed当不打印到终端时将以缓冲模式工作.这意味着默认情况下它将尝试填充内部缓冲区,然后再进行任何处理和输出.

sed will work in buffered mode when it doesn't print to a terminal. This means that it will try to fill its internal buffer before doing any processing and output by default.

这样做是为了增加吞吐量,因为通常在管道中,您无需关心时间,而是希望在给定时间内处理尽可能多的数据.

This is done to increase throughput, because normally in a pipe you don't care about the timing, but want as much data processed in a given time as possible.

-u传递给sed将使其不带缓冲地工作,因此以与输出到终端时相同的方式工作.

Passing -u to sed will tell it to work unbuffered, therefore working the same way it works when output goes to a terminal.

这篇关于sed是否阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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