GNU bug report logs -
#11220
uniq -d and -Du bug?
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
What should this print?
echo -e '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';
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
To see what duplicated line is printed I tried this:
echo -e 'a1\na2\na3\na4\n' | uniq -d -w 1
a1
So, first line is printed. This is not what I expected at all.
Now, -D means 'print all duplicate lines' and
echo -e 'aa\naa\naa\n' | uniq -D
prints what I expect it to:
aa
aa
aa
Now, -D and -u means 'print all duplicate lines' and 'only print unique
lines'.
I think this should print all lines since union of all unique lines and all
duplicate lines is all lines.
But,
echo -e 'aa\naa\naa\n' | uniq -Du
prints this:
aa
aa
To see what lines are being printed I tried this:
echo -e 'a1\na2\na3\na4\n' | uniq -Du -w 1
a1
a2
a3
Therefore -Du prints first N-1 matching lines and not last matching line.
(Which is sort-of like what I expect -d to print)
Are these bugs?
[Message part 2 (text/html, inline)]
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.