bug-coreutils
[Top][All Lists]
Advanced

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

Re: mistake in sort -k argument processing?


From: Evan Hunt
Subject: Re: mistake in sort -k argument processing?
Date: Wed, 27 Dec 2006 16:43:31 -0800
User-agent: Mutt/1.5.10i

> > Very well.  In that case, let's edit the documentation to reflect that .0
> > represents the end of the field, and I'll be happy.
> 
> I would welcome a patch (to coreutils.texi) to do that.

Okay.  First kick at the can is below; if you think it's too verbose, I can
try to tersify it some.

Evan Hunt

----------------
$ diff -c coreutils.texi.00 coreutils.texi
*** coreutils.texi.00   2006-12-27 15:45:05.000000000 -0800
--- coreutils.texi      2006-12-27 16:32:47.000000000 -0800
***************
*** 3580,3588 ****
  @cindex sort field
  Specify a sort field that consists of the part of the line between
  @var{pos1} and @var{pos2} (or the end of the line, if @var{pos2} is
! omitted), @emph{inclusive}.  Fields and character positions are numbered
! starting with 1.  So to sort on the second field, you'd use
! @option{--key=2,2} (@option{-k 2,2}).  See below for more examples.
  
  @item -o @var{output-file}
  @itemx address@hidden
--- 3580,3600 ----
  @cindex sort field
  Specify a sort field that consists of the part of the line between
  @var{pos1} and @var{pos2} (or the end of the line, if @var{pos2} is
! omitted), @emph{inclusive}.
! 
! Each @var{pos} has the form @address@hidden@address@hidden,
! where @var{f} is the number of the field to use, and @var{c} is the number
! of the first character from the beginning of the field.  Fields and character
! positions are numbered starting with 1; a character position of zero in
! @var{pos2} indicates the field's last character.  If @address@hidden is
! omitted from @var{pos1}, it defaults to 1 (the beginning of the field);
! if omitted from @var{pos2}, it defaults to 0 (the end of the field).
! @var{opts} are ordering options, allowing individual keys to be sorted
! according to different rules; see below for details.  Keys can span
! multiple fields.
! 
! Example:  To sort on the second and third fields, use @option{--key=2,3}
! (@option{-k 2,3}).  See below for more examples.
  
  @item -o @var{output-file}
  @itemx address@hidden
***************
*** 3721,3749 ****
  affect the meaning of character positions in field specifications in
  obscure cases.  The only fix is to add an explicit @option{-b}.
  
! A position in a sort field specified with the @option{-k}
! option has the form @address@hidden@var{c}}, where @var{f} is the number
! of the field to use and @var{c} is the number of the first character
! from the beginning of the field.  In a start position, an omitted
! @address@hidden stands for the field's first character.  In an end
! position, an omitted or zero @address@hidden stands for the field's
! last character.  If the start field falls after the end of the line
! or after the end field, the field is empty.  If the
! @option{-b} option was specified, the @address@hidden part of a field
! specification is counted from the first nonblank character of the field.
! 
! A sort key position may also have any of the option letters @samp{Mbdfinr}
! appended to it, in which case the global ordering options are not used
! for that particular field.  The @option{-b} option may be independently
! attached to either or both of the start and
! end positions of a field specification, and if it is inherited
! from the global options it will be attached to both.
  If input lines can contain leading or adjacent blanks and @option{-t}
  is not used, then @option{-k} is typically combined with @option{-b},
  @option{-g}, @option{-M}, or @option{-n}; otherwise the varying
  numbers of leading blanks in fields can cause confusing results.
  
! Keys can span multiple fields.
  
  @vindex _POSIX2_VERSION
  @vindex POSIXLY_CORRECT
--- 3733,3753 ----
  affect the meaning of character positions in field specifications in
  obscure cases.  The only fix is to add an explicit @option{-b}.
  
! A position in a sort field specified with @option{-k} may have any
! of the option letters @samp{Mbdfinr} appended to it, in which case the
! global ordering options are not used for that particular field.  The
! @option{-b} option may be independently attached to either or both of
! the start and end positions of a field specification, and if it is
! inherited from the global options it will be attached to both.
  If input lines can contain leading or adjacent blanks and @option{-t}
  is not used, then @option{-k} is typically combined with @option{-b},
  @option{-g}, @option{-M}, or @option{-n}; otherwise the varying
  numbers of leading blanks in fields can cause confusing results.
  
! If the start position in a sort field specifier falls after the end of
! the line or after the end field, the field is empty.  If the @option{-b}
! option was specified, the @address@hidden part of a field specification
! is counted from the first nonblank character of the field.
  
  @vindex _POSIX2_VERSION
  @vindex POSIXLY_CORRECT




reply via email to

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