[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sorting with -u and -k
From: |
Paul Eggert |
Subject: |
Re: sorting with -u and -k |
Date: |
Thu, 24 Jan 2008 12:32:16 -0800 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Joost Helberg <address@hidden> writes:
> given options '-t: -k2 -k3' the following lines compare equal:
>
> foo:1:2
> oof:1:2
>
> hence, the oof-line doesn't appear in case -u was used.
>
> This strikes me as a surprise, I expected that these two lines would
> compare as non-equal. I cannot find any explicit reference in the
> manual indicating this as correct behaviour (only one example is
> given: -n).
Thanks for mentioning this. Here's a proposed fix to the manual
to explain this more carefully.
2008-01-24 Paul Eggert <address@hidden>
* coreutils.texi (sort invocation): -u inspects only specified fields.
Problem reported by Joost Helberg.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 3785eae..3741e5d 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -3793,6 +3793,8 @@ this equivalence does not extend to arbitrary
@command{sort} options.
For example, @code{sort -n -u} inspects only the value of the initial
numeric string when checking for uniqueness, whereas @code{sort -n |
uniq} inspects the entire line. @xref{uniq invocation}.
+Similarly, @code{sort -k 4,4 -u} inspects only the fourth field when
+determining whether two lines differ.
@item -z
@itemx --zero-terminated
- Re: sorting with -u and -k,
Paul Eggert <=