Subject: Feature request: uniq -k

From: Raphael Clifford <[email-masked]>
Date: Sat, 3 Apr 2010 19:39:14 +0100

Please excuse the cross-post but I have been told this is the
appropriate place to place a feature request.

Is it possible to make a feature request for uniq to add the "-k"
option to specify
fields?  Interestingly uniq already has such things as

-f, --skip-fields=N
             avoid comparing the first N fields
and

 -s, --skip-chars=N
             avoid comparing the first N characters

but no explicit option to specify which fields should be considered
when doing the comparison.  This would be very useful, for example,
when removing duplicates from time series data (where you are only
worried about consecutive duplicates on certain fields).  The awk
equivalent would be something like

awk '$2$3$4$5 !=  p; {p=$2$3$4$5}'

for using fields 2 to 5 as comparators.

Raphael

P.S. http://www.opengroup.org/onlinepubs/9699919799/utilities/uniq.html
is the posix specification for uniq if that is of any interest.
Curiously it says nothing about which duplicate line to keep when you
don't consider all fields in the comparison.