coreutils
[Top][All Lists]
Advanced

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

Re: Sort with header/skip-lines support


From: Pádraig Brady
Subject: Re: Sort with header/skip-lines support
Date: Fri, 11 Jan 2013 19:37:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 01/11/2013 07:19 PM, Assaf Gordon wrote:
Hello Pádraig,

Your suggestions work for all the cases I needed, so essentially there's 
already a way to do sort+header - much appreciated!

Pádraig Brady wrote, On 01/11/2013 01:13 PM:
On 01/11/2013 04:10 PM, Assaf Gordon wrote:
Pádraig Brady wrote, On 01/10/2013 07:11 PM:

The following indeed works with sed 4.2.2 ( on linux 3.2 ):
     $ ( echo 99 ; seq 10 ) | ( sed -u 1q ; sort -n )

[2] - no pipe support: 
http://lists.gnu.org/archive/html/bug-coreutils/2007-07/msg00215.html
But I'm wondering (as per the link above [2]) if this is posix compliant and 
stable (i.e. can this be trusted to work everytime, even on non-linux 
machines?).

No `sed -u` with this functionality is not portable.
Though it's more portable than `sort --header`
given that it already exists :)

Sorry for nitpicking, but just to verify:
"sed -u" is a GNU extension, hence not portable by definition.
But what I meant to ask:
If I install GNU sed + GNU sort on any machine (e.g. MAC OSX), would it work in 
a reliable way?
Eric Blake's email seemed to suggest this will never be guaranteed to work 
(even if it works in practice) due to sharing pipes between processes.

Eric's point I think is that there is no guarantee
that processes will not read too much from the pipe.
But if you have GNU sed >= 4.2.2 in place then it
should work fine, as he alluded to in the sh exception.

thanks,
Pádraig.



reply via email to

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