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: Jim Meyering
Subject: Re: mistake in sort -k argument processing?
Date: Wed, 03 Jan 2007 12:15:48 +0100

Evan Hunt <address@hidden> wrote:
>> > 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.

Thank you!
I've applied that with one small change:
I prefer not to change the -k2,2 example to -k2,3,
since with the latter we'd have to explain clearly
that it is sorting on the concatenation of fields
2 and 3, which is not the same as -k2,2 -k3,3, where the
two fields serve as separate keys.

        * coreutils.texi (sort invocation): Specify what the ".0" in e.g.,
        "-k 2,3.0" means, and that it can be applied to the field-end spec,
        but not the field-start one.  Patch from Evan Hunt.

Full details here:
  http://git.sv.gnu.org/gitweb/?p=coreutils.git

FYI, considering that your patch was mostly reorganizing
existing text, I figure you've just barely slipped under the
needs-copyright-papers bar.

> ----------------
> $ 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.
...




reply via email to

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