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


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

From: "Brian J. Murrell" <brian <at> interlinx.bc.ca>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 44704 <at> debbugs.gnu.org
Subject: Re: bug#44704: uniq: replace repeated lines with a message about
 how many repeated lines
Date: Tue, 17 Nov 2020 17:18:07 -0500
[Message part 1 (text/plain, inline)]
On Tue, 2020-11-17 at 14:10 -0800, Paul Eggert wrote:
> On 11/17/20 5:32 AM, Brian J. Murrell wrote:
>  > [previous line repeated 4 times]
> 
> uniq -c already does something like that, though it outputs "5"
> instead of "4". 

Right.  I had considered that.  Something like:

$ cat /tmp/in | uniq -c | while read c line; do
> echo $line
> if [ $c -gt 1 ]; then
> echo "Last line repeated $((c-1)) times"
> fi
> done

But that eats leading whitespace on $line.

> Not sure it's worth gussying up 'uniq' to provide exactly the
> functionality 
> requested, as output reformatting is easy enough to do yourself using
> awk or 
> Python or whatever.

Right.  But if I were going to pull out such a big hammer, I'd just
again, eliminate uniq and do everything in awk or Python or whatever.

Anyway, it was just a suggestion.  Doesn't seem like it will go much of
anywhere.  That's fine.  If it really itched me enough, I guess I'd
just submit a patch.

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.