Subject: Re: bug#9995: problem about sort -u -k

From: Eric Blake <[email-masked]>
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   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org