nmh-workers
[Top] [All Lists]

Re: check if message is in a particular sequence?

2021-04-30 16:44:57
Hi Paul,

I thought I'd be able to compare the message number against the output
of "mark -list", but since sequences can be abbreviated with range
notation, that gets complicated quickly.  For example, message 6 is in
the sequence todo, but it's hard to tell from this:
    $ mark -list -sequence todo
    todo: 1 3 5-8 13 16 46 49 52-53

This will expand the message numbers printed by mark(1) making a check
by something like ‘fgrep -qx 42’ trivial.

    mark -list -seq public -seq private -seq notexist |
    sed 's/.*: //' |
    awk '{
        for (n = 1; n <= NF; n++) {
            c = split($n, w, /-/)
            a = w[1]; b = c == 1 ? w[1] : w[2]
            for (m = a; m <= b; m++) print m
        }
    }'

(My ~/bin/toseq happens to do roughly the opposite, compressing
sequential numbers into a range.  :-)

-- 
Cheers, Ralph

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