nmh-workers
[Top] [All Lists]

Re: check if message is in a particular sequence?

2021-05-01 06:59:28
I'll shut up soon.

    mark -list -seq public -seq private -seq notexist |
    awk -v RS=' ' -F - '
      $0+0 {u = NF==2 ? $2 : $1; for (n = $1+0; n <= u; n++) print n}
    '

I thought I may as well create this and see if it gets used.

    $ cat ~/bin/mhinseq
    #! /bin/sh

    # Successfully exit only if the message is in the sequence.
    # usage: mhinseq seq 42

    mark -list -sequence "${1?}" |
    awk -v RS=' ' -F - -v msg="${2?}" '
            $0+0 &&
                ((NF == 1 && $1+0 == msg) ||
                 (NF == 2 && $1 <= msg && msg <= $2)) {f=1; last}
            END {exit !f}
        '
    $ 

-- 
Cheers, Ralph.

<Prev in Thread] Current Thread [Next in Thread>