coreutils
[Top][All Lists]
Advanced

[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

Hello,

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:
https://lists.gnu.org/r/coreutils/2013-02/msg00087.html
https://lists.gnu.org/r/coreutils/2016-04/msg00063.html

Additionally, I came across Pádraig's suggestion
to create a 'decorate' program:
https://lists.gnu.org/r/bug-coreutils/2015-06/msg00076.html
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
  AAA,BBB,MMXIX,2019

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

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


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]