[Top][All Lists]

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

bug#11220: uniq -d and -Du bug?

From: Jim Meyering
Subject: bug#11220: uniq -d and -Du bug?
Date: Wed, 11 Apr 2012 13:59:31 +0200

phil colbourn wrote:

> What should this print?
> echo -e 'aa\naa\naa\n' | uniq -d

It's better to avoid echo -e.  Use printf instead:

    printf 'aa\naa\naa\n' | uniq -d

> To me this says:
> 1. uniqueness is defined by whole line so there is 1 unique value 'aa';
> 2. -d option say to 'only print duplicate lines';

When in doubt, follow the advice at the bottom of the man page
and read the "real" (texinfo) documentation:

       The full documentation for uniq is maintained as a Texinfo manual.   If
       the  info  and  uniq  programs are properly installed at your site, the

              info coreutils 'uniq invocation'

       should give you access to the complete manual.

> 3. 1st 'aa' is (so far) unique so it should NOT be printed;
> 4. 2nd 'aa' is not unique so it SHOULD be printed; and
> 5. 3rd 'aa' is not unique so it SHOULD also be printed.
> I think I should get this:
> aa
> aa
> But I get this:
> aa

Thanks for the report.
The problem is that the description in the man page is too succinct,
perhaps because -d means different things, depending on what other
options you use it with.

How is what you see inconsistent with the documentation?
(info coreutils uniq)

     Discard lines that are not repeated.  When used by itself, this
     option causes `uniq' to print the first copy of each repeated line,
     and nothing else.

reply via email to

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