[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort's -u is Failing to Check all -k fields for Uniqueness.
From: |
Andreas Schwab |
Subject: |
Re: sort's -u is Failing to Check all -k fields for Uniqueness. |
Date: |
Sat, 19 Aug 2006 16:13:29 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) |
Ralph Corderoy <address@hidden> writes:
> $ echo 1/3,1/2,1/1,2/1 | tr , \\012 | sort -nu -t / -k 1,2
> 1/3
> 2/1
> $
>
> -u should only filter out lines that compare equal on *all* key fields.
There is only one sort key, which spans the first two fields of each line,
and -n tells sort to only consider the numeric prefix of each key. If you
want to sort on multiple keys you need to specify each key separately.
$ echo 1/3,1/2,1/1,2/1 | tr , \\012 | sort -nu -t / -k 1,1 -k2,2
1/1
1/2
1/3
2/1
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."