GNU bug report logs -
#44704
uniq: replace repeated lines with a message about how many repeated lines
Previous Next
Full log
View this message in rfc822 format
[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.