nmh-workers
[Top][All Lists]
Advanced

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

Re: check if message is in a particular sequence?


From: Ralph Corderoy
Subject: Re: check if message is in a particular sequence?
Date: Fri, 30 Apr 2021 22:18:58 +0100

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



reply via email to

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