[Bug 275764] `uniq -D -c` gives wrong values of repeat counts
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 275764] `uniq -D -c` gives wrong values of repeat counts"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Dec 2023 07:41:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275764
Daniel Tameling <tamelingdaniel@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tamelingdaniel@gmail.com
--- Comment #1 from Daniel Tameling <tamelingdaniel@gmail.com> ---
Created attachment 247279
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=247279&action=edit
possible patch
The reason for this is that the code is designed for printing the repetition
counts in front of the previous line. But if -D is specified, it prints the
current line with the exception of the first duplicate. Thus, if one increases
the count before printing and not after, one gets a better result:
$ uniq -D -c animals.txt
1 bear
2 bear
1 camel
2 camel
3 camel
1 fish
2 fish
1 koala
2 koala
3 koala
--
You are receiving this mail because:
You are the assignee for the bug.