GNU bug report logs - #9995
problem about sort -u -k

Previous Next

Package: coreutils;

Reported by: 夏凯 <walkerxk <at> gmail.com>

Date: Tue, 8 Nov 2011 17:25:15 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
To: 夏凯 <walkerxk <at> gmail.com>, 9995 <at> debbugs.gnu.org
Subject: bug#9995: problem about sort -u -k
Date: Wed, 09 Nov 2011 07:58:42 -0700
[Let's keep the list in the loop]

On 11/08/2011 07:58 PM, 夏凯 wrote:
> thanks for you reply.
> if i want to get my result, whether should i use sort -u -k3 -k1 -k2 a
> to do that?
>

I'm still not quite sure what result you want.

sort -u -k3 -k1 -k2 a

says to sort with three keys - from field 3 to the end of the line, from 
field 1 to the end of the line (aka the entire line), and from field 2 
to the end of the line (that -k2 is useless, since sorting by field 1 to 
the end of the line already sorted everything so that there is no longer 
any distinguishing factors from field 2 to the end of the line).  Then, 
after sorting, sort discards any lines where all three keys are 
identical, and since the -k1 key was the entire line, you are discarding 
only duplicate lines.  But I don't know if that is what you wanted.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




This bug report was last modified 13 years and 255 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.