LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-31-2006, 03:48 PM   #1
jahvascriptmaniac
Member
 
Registered: Aug 2006
Posts: 34

Rep: Reputation: 15
Sed gives output in pipes only when buffer is full


Hi !
I basicly tried to run the following command :
command | sed -e 's/something/something else/' | command_2
snd it gives the output in huge chunks instead of nicely giving output lines at the input lines' speed.

By playing a little with things like :
sed something | cat
I understood that it only gave the output when the buffer (8192 chars) was full. But it works fine with no redirection after sed.
I read half of /usr/share/doc/sed-*/index.html (or similar) but couldn't find anything mentionning this.

I tried with variants of :
sed -e 's/a/b/; p'
and
sed -n -e 's/a/b/; p'
but it's still doesn't work.

Could someone tell me how to explain to sed that I want it to spit out each line of input to the output without stupidly waitig; to be nice like it is without any redirection afterwards ???

BTW. The bug is only visible if the input isn't in one whole chunk, you should put a few usleep's in the input in order to reproduce the bug.
 
Old 08-31-2006, 04:06 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Although I doubt that sed is the problem, here's a way to 'check': Use sed's -u (--unbuffered) option and see what happens.

I've seen this behavior before, but sed was not the problem, the command before/after the pipe was, that's the reason for doubt about sed being the problem.

Anyway, hope this gets you going again.
 
Old 08-31-2006, 05:57 PM   #3
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
We've had something similar here: http://www.linuxquestions.org/questi...d.php?t=457732
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy output of Terminal Buffer tryangle Debian 2 08-08-2005 04:09 PM
weird sed output schneidz Programming 3 05-19-2005 11:16 AM
insert output of sed into a variable hwouters Linux - General 3 11-06-2004 07:54 PM
Keyboard output buffer Majestros Linux - Hardware 0 07-06-2004 09:01 AM
sed and its hold buffer???????? 3inone Programming 2 05-07-2004 05:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration