[Top][All Lists]

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

sort/join/uniq + decorate: key-comparison code improvements

From: Assaf Gordon
Subject: sort/join/uniq + decorate: key-comparison code improvements
Date: Sat, 16 Mar 2019 21:40:10 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1


Resuming an old topic, attached is an updated patch which
extracts sort's key-comparison code into a separate module,
then uses the module to implement improved key comparison
in join,uniq.

[PATCH 1/4] sort: extract key-comparison functionality to a separate
[PATCH 2/4] join: add key-comparison options
[PATCH 3/4] uniq: add new "-k/--key=KEYDEF" functionality
[PATCH 4/4] decorate: new program (DRAFT)

Previous discussed in:

Additionally, I came across Pádraig's suggestion
to create a 'decorate' program:
and with the key-comparison module, it is now easy (more or less)
to implement - attached a draft patch.

The program behaves like so:

  $ printf "AAA,BBB,MMXIX\n" | decorate -t, -k3,3:roman

  $ printf "FOO BAR\n" | decorate -k2,2:ipv4
  FOO BAR 0a042d48

  $ printf "%s\n" A AAA AAAAAA | decorate -k1,1:strlen
  A 1
  AAA 3

If you think this is a bit too bloat-y for coreutils,
I will add this functionality to gnu datamash
(which already performs similar functions of processing
fields in lines of text).

Comments welcomed,
 - assaf

Attachment: key-compare-decorate-2019-03-16.patch.gz
Description: application/gzip

reply via email to

[Prev in Thread] Current Thread [Next in Thread]