bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sort -u produces incorrect output


From: Bailey, Scott
Subject: sort -u produces incorrect output
Date: Thu, 24 Aug 2006 17:56:04 -0400

Consider this test case, which performs identically with sort 5.96 (on
Debian/alpha) and sort 5.2.1 (on SLES9/x86_64):

# cat << EOF > x.x
one one
two one
two two
one one
EOF
# sort -u -k1 x.x
one one
two one
two two
# sort -u -k1 -s x.x
one one
two one
two two
#

Quoth POSIX: "-u   Unique: suppress all but one in each set of lines
having **EQUAL KEYS**." [Emphasis added]
http://www.opengroup.org/onlinepubs/000095399/utilities/sort.html This
matches the info text provided by SuSE, while the Debian documentation
is more vague.

Because only a single key is specified, it seems obvious that the
correct output from the last (stable) case must be:

one one
two one

and that the first test case should return "one one" followed by exactly
one of "two one" or "two two" (as both have identical keys and
consequently only one can be selected).

It appears the uniqueness test is applied to the entire data line,
rather than only the specified keys as required by POSIX.

In the meantime, my database loads keep bombing because my unique keys
aren't. :-)

Thanks,

Scott Bailey
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]