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: norm
Subject: Re: [Nmh-workers] A permute command for nmh 1.7 ?
Date: Tue, 17 Jun 2014 13:25:31 -0700

Ralph Corderoy <address@hidden> writes:
> Hi Jererad,
>
> > Putting the specified messages into the specified order is trivial,
> > but where do they go in the overall order of the folder?
>
> As Norm's clarified said, things are just being moved within the same
> message numbers.
>
> > If they are to be inserted into one another's slots,
> > I see no sane way to define how that would work.
>
> Let's get some sample arguments to this new script.
>
>     $ set `seq 42 | shuf | sed 13q`
>     $ echo $*
>     25 4 3 31 29 41 9 13 2 26 23 20 10
>     $
>
> Norm wants the current 25 to sit in the smallest of those messages instead.
>
>     $ l=`printf '%s\n' $*`
>     $ echo "$l" | sort -n | fmt
>     2 3 4 9 10 13 20 23 25 26 29 31 41
>     $
>
> So 25's content trample's 2's.  Obviously, we want 2's somewhere else
> beforehand.
>
> One can imagine backing up all the files and moving the backups to their
> destination, but that creates a lot of duplication along the way.  An
> alternative is to topologically sort the mapping of source -> destination
> and use that to do the copies in an order, breaking the cycles with a
> backup copy when it's really necessary.  (There's tsort(1) but it
> dislikes cycles.)
>
> 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
>     $
>
> So,
>
>     mv  2   t
>     mv  25  2
>     mv  t   25
>
>     mv  3   t
>     mv  4   3
>     mv  t   4
>
>     mv  9   t
>     mv  31  9
>     mv  20  31
>     mv  t   20
>
>     mv  13  t
>     mv  41  13
>     mv  10  41
>     mv  29  10
>     mv  23  29
>     mv  t   23

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.




reply via email to

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