On 11/20/2014 07:24 AM, Bradley Dean wrote:
Thanks! Piping through ( sed -u 1q && sort ... ) works for me and is
less typing than my example workaround.

BTW: Please note that older sed versions might slurp more input than
needed - even with the -u option - e.g. on SLES11 the subsequent sort
won't see any input (sed 4.1.5):

  $ df | { sed -u 1q && sort -k5,5n; }
  Filesystem                 1K-blocks      Used Available Use% Mounted on

BTW2: Although "sed -u 1q" should be the ~same as "head -n1", the latter
also consumes the whole df(1) output (even the latest git version):

  $ src/df | { src/head -n1 && src/sort -k5,5n; }
  Filesystem                          1K-blocks      Used Available Use% 
Mounted on

It's not clear for me from the specification [0] wether head(1) is
allowed to consume more than specified by the -n option.
Padraig?

[0]
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html

Have a nice day,
Berny


Reply via email to