Subject: bug#10365: [PATCH] uniq: add ability to skip last N chars or fields

From: Pádraig Brady <[email-masked]>
Date: Mon, 26 Dec 2011 16:35:37 +0000

On 12/25/2011 12:54 PM, Adrien Kunysz wrote:
> * doc/coreutils.texi: document the new feature
> * src/uniq.c (find_end): new function
> (check_file): use find_end() to determine when to stop comparing
> (usage): document the new feature
> (main): expose the new feature to user
> * tests/misc/uniq: add tests to exercise the new code
> ---
>  doc/coreutils.texi |   17 +++++++++++++
>  src/uniq.c         |   69 +++++++++++++++++++++++++++++++++++++++++++++++++---
>  tests/misc/uniq    |   15 +++++++++++
>  3 files changed, 97 insertions(+), 4 deletions(-)
> 
> I have recently found myself wishing I could have uniq(1) skip
> the last N fields before comparison. I am aware of the rev(1) trick
> but I don't find it very satisfactory. So I ended up patching uniq
> and implementing the feature for characters skipping as well.
> 
> Documentation and tests included. Tests have also been run within
> Valgrind on x86_64.

Thank you for being so thorough.

Hmm, this is quite unusual functionality.
I was about to merge this with a previous feature request:
http://debbugs.gnu.org/5832
But in fact supporting --key would not provide this functionality.

Why does `rev | uniq -f | rev` not suffice for you?

BTW you would need to start the copyright assignment process for
this feature, but we'd have to decide if it generally useful enough
to proceed. Perhaps a concrete example would help.

cheers,
Pádraig.