coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [head] wished an option to continue consuming the input after the sp


From: Pádraig Brady
Subject: Re: [head] wished an option to continue consuming the input after the specified number of lines has been read
Date: Mon, 14 Jan 2013 00:25:05 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 10/16/2012 09:07 AM, Thibault LE PAUL wrote:
Hello Bob.

I wasn't clear enough.
My goal was to do different things on the first lines and the last lines of 
same input, without using storage, thus using piped processes.
Then I used tee, to fork the pipe into two processes.
In my post before, I wanted to show three ways that work, including (head; cat) 
that does exactly the same as what would do head with the option I suggested in 
my initial post.
Opposite to that, my original way that fails :

rm /tmp/fifo1
mkfifo /tmp/fifo1
cat /tmp/fifo1|head -n2|sed 's/^/head &/' &
tee /tmp/fifo1|tail -n2|sed 's/^/tail &/'

That way, the /tmp/fifo1 fifo propagates SIGPIPE ahead to tee as soon as head 
has finished, then tee stops, and tail doesn't read the expected last lines, 
instead just the lines before tee aborts and EOF is read on pipe. The effect is 
observable on large input, like /usr/share/mysql/errmsg-utf8.txt
Also tried tee -i to ignore interrupts, but it is not the purpose of this 
option I suppose. No effect in our case.

Note we're seriously considering adding --write-error={[cont],ignore,exit}
to support applications like this.
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11540

thanks,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]