RFC: improved support for grouping in uniq (original) (raw)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Pádraig Brady
Subject: RFC: improved support for grouping in uniq
Date: Wed, 02 Mar 2011 16:44:12 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

-d, -D and -u make sense when used in isolation:

$ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 -D 2 a 2 b 2 c $ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 -u 1 a 3 a pb-laptop:~$ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 -d 2 a

However when you combine -u (suppress last output entry in a repeated group) with -d or -D it doesn't seem useful:

$ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 -d -u $ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 -D -u 2 a 2 b

Why I'm asking is to perhaps overload -u -D to support grouping like:

$ printf "1 a\n2 a\n2 b\n2 c\n3 a\n" | uniq -w1 --unique=separated --all-repeated=separated 1 a

2 a 2 b 2 c

3 a

Or maybe we should just add a new --group option to do the above?

On a related note, if I want to subsequently split that, I can: csplit '/^$/' '{*}' but that leaves the blank lines in the files. I've often wished there was an option to suppress the matched line.

cheers. Pádraig.