GNU bug report logs - #44704
uniq: replace repeated lines with a message about how many repeated lines

Previous Next

Package: coreutils;

Reported by: "Brian J. Murrell" <brian <at> interlinx.bc.ca>

Date: Tue, 17 Nov 2020 14:14:01 UTC

Severity: wishlist

Tags: notabug

Full log


View this message in rfc822 format

From: "Brian J. Murrell" <brian <at> interlinx.bc.ca>
To: Assaf Gordon <assafgordon <at> gmail.com>, 44704 <at> debbugs.gnu.org
Subject: bug#44704: uniq: replace repeated lines with a message about how many repeated lines
Date: Tue, 17 Nov 2020 10:28:53 -0500
[Message part 1 (text/plain, inline)]
On Tue, 2020-11-17 at 08:05 -0700, Assaf Gordon wrote:
> 
> Hello,

Hi,

> uniq supports the "--group" option, which adds a blank line after
> each
> group of identical lines - this can be used down-stream to process
> groups in any way you want.

But there is no way to have it remove the repeated lines also, correct?

By down-stream process, I feel like you are leaving it up to the down-
stream to remove the duplicate lines as well as add the "repeated %s
times" messages.  Is that correct?

If so, uniq really adds no value.  The down-stream might as well just
do the adjacent line comparison also in such a case.

> And with counting:
> 
> $ cat in | uniq --group=append \
>       | awk 'BEGIN { c = 0 } ;
>              $0=="" { print "Group has " c " lines" ; c=0 ; next } ;
>              1 { print ; c++ }'
>    first line
>    Group has 1 lines
>    second line
>    Group has 1 lines
>    repeated line
>    repeated line
>    repeated line
>    repeated line
>    repeated line
>    Group has 5 lines
>    third line
>    Group has 1 lines

This still doesn't really achieve the original stated goal as the
repeated lines are not being replaced by your "Group has %d lines".

I think once you add the repeated line suppression, you will see that
adding a simple adjacent line comparison and just not using uniq at all
is only slightly incrementally more in the down-stream (which is now
the main).

Cheers,
b.

[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 4 years and 273 days ago.

Previous Next


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