bug-coreutils
[Top][All Lists]
Advanced

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

Re: Uniq command gives wrong and different results


From: Bob Proulx
Subject: Re: Uniq command gives wrong and different results
Date: Wed, 11 Oct 2006 11:00:25 -0600
User-agent: Mutt/1.5.9i

Fong Tin Joen, Raimund wrote:
> When using the uniq command on the delivered file the result is not
> as expected.  It als gives random results depending on using it
> several times after eachother.

Your file is not sorted.  Sort the file first.  The sort documentation
says:

     By default, `uniq' prints its input lines, except that it discards
  all but the first of adjacent repeated lines, so that no output lines
  are repeated.  Optionally, it can instead discard lines that are not
  repeated, or all repeated lines.

     The input need not be sorted, but repeated input lines are detected
  only if they are adjacent.  If you want to discard non-adjacent
  duplicate lines, perhaps you want to use `sort -u'.

Because the file is not sorted the duplicated lines are not adjacent
and fail the adjacency requirement.

Try this:

  sort Foo | uniq -u

That will show that there are no unique lines in the file.

Bob




reply via email to

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