nmh-workers
[Top][All Lists]
Advanced

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

Re: [Nmh-workers] A permute command for nmh 1.7 ?


From: Ralph Corderoy
Subject: Re: [Nmh-workers] A permute command for nmh 1.7 ?
Date: Wed, 18 Jun 2014 14:05:52 +0100

Hi Norm,

> > Here's where each has to end up.
> >
> >     $ paste <(echo "$l") <(echo "$l" | sort -n) | awk '$1 != $2'
> >     25      2
> >     4       3
> >     3       4
> >     31      9
> >     29      10
> >     41      13
> >     9       20
> >     13      23
> >     2       25
> >     23      29
> >     20      31
> >     10      41
> >     $
>
> There are two questions. One is what should be done. You have answered
> that well. The second question is how should it be done. My answer
> would be, the way sortm does it.

Great minds...  :-)  Though I was wondering if something like this would
do.  Continuing with the above mapping, let's get some emails.

    $ for f in {1..42}; do
    >     printf '%s\n' "Subject: Originally $f" \
    >         'Date: Tue, 17 Jun 2014 21:25:31 +0100' >$f
    > done
    $
    $ scan -forma '%4(msg) %{subject}' last:3
      40 Originally 40
      41 Originally 41
      42 Originally 42
    $

Now annotate those to permute with where they will end up.

    $ paste <(echo "$l") <(echo "$l" | sort -n) |
    > while read src dest; do
    >     anno -preserve -nodate -component norm-order -text `printf %09d 
$dest` $src
    > done
    $
    $ scan -forma '%4(msg) %15{subject} %{norm-order}' 1-5
       1 Originally 1
       2 Originally 2    000000025
       3 Originally 3    000000004
       4 Originally 4    000000003
       5 Originally 5
    $

Then sortm the emails on that field, as they're all distinct the date
will be ignored.

    $ sortm -textfield norm-order -limit 0 $l
    $ scan -forma '%4(msg) %15{subject} %{norm-order}'
       1 Originally 1
       2 Originally 25   000000002
       3 Originally 4    000000003
       4 Originally 3    000000004
       5 Originally 5
       6 Originally 6
       7 Originally 7
       8 Originally 8
       9 Originally 31   000000009
      10 Originally 29   000000010
      11 Originally 11
      12 Originally 12
      13 Originally 41   000000013
      14 Originally 14
      15 Originally 15
      16 Originally 16
      17 Originally 17
      18 Originally 18
      19 Originally 19
      20 Originally 9    000000020
      21 Originally 21
      22 Originally 22
      23 Originally 13   000000023
      24 Originally 24
      25 Originally 2    000000025
      26 Originally 26   000000026
      27 Originally 27
      28 Originally 28
      29 Originally 23   000000029
      30 Originally 30
      31 Originally 20   000000031
      32 Originally 32
      33 Originally 33
      34 Originally 34
      35 Originally 35
      36 Originally 36
      37 Originally 37
      38 Originally 38
      39 Originally 39
      40 Originally 40
      41 Originally 10   000000041
      42 Originally 42
    $

And remove the temporary header.

    $ anno -preserve -nodate -component norm-order -delete $l
    $

Cheers, Ralph.



reply via email to

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