[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort -u -n error : sort v 4.5.3
From: |
Eric Blake |
Subject: |
Re: sort -u -n error : sort v 4.5.3 |
Date: |
Sun, 05 Mar 2006 02:53:18 +0000 |
The most recent stable version of coreutils is 5.94; consider upgrading
(although that does not change your report).
> Sort : the -u (unique) and -n (numeric) options seem to clash, removing too
> many lines.
>
>
> address@hidden data]# cat /tmp/new_spammers
> 64.202.165.132
> 64.202.165.131
> 64.202.165.133
>
>
> address@hidden data]# sort -u < /tmp/new_spammers
> 64.202.165.131
> 64.202.165.132
> 64.202.165.133
>
> [
> address@hidden data]# sort -n < /tmp/new_spammers
> 64.202.165.131
> 64.202.165.132
> 64.202.165.133
>
>
> address@hidden data]# sort -u -n < /tmp/new_spammers
> 64.202.165.132
Not a bug. This behavior is required by POSIX,
http://www.opengroup.org/onlinepubs/009695399/utilities/sort.html,
which states that -n restricts the key to the first numeric
field, and that -u uniquifies based on the sort key.
In your sample file, the unique key is 64, and all
three lines have the same key. When -n or -u is
used alone, a tiebreaker is used that sorts based
on the rest of the line. But when used together,
the behavior correctly stops after one line.
--
Eric Blake