GNU bug report logs - #11220
uniq -d and -Du bug?

Previous Next

Package: coreutils;

Reported by: phil colbourn <philcolbourn <at> gmail.com>

Date: Wed, 11 Apr 2012 06:25:01 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 11220 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: phil colbourn <philcolbourn <at> gmail.com>
Cc: 11220 <at> debbugs.gnu.org
Subject: Re: 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
       command

              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)

`-d'
`--repeated'
     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.




This bug report was last modified 13 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.