nmh-workers
[Top] [All Lists]

Re: check if message is in a particular sequence?

2021-05-01 06:43:42
Hi,

I wrote:
    $ mark -list -seq public -seq private -seq notexist
    public: 1-3 42
    private (private): 3141 97057-97059
    notexist: 
    $
    $ mark -list -seq public -seq private -seq notexist |
    > gawk -v RS=' |\n' -F - '
    >     $0+0 {u = NF==2 ? $2 : $1; for (n = $1; n <= u; n++) print n}
    > '
    1
    2
    3
    42
    3141
    97057
    97058
    97059
    $

Silly me.  No need for gawk's regexp RS as the ‘42\nprivate’ which
arrives with just the POSIX RS=' ' always has something to discard after
the linefeed so there's no need to split it off into its own record.
Thus, the above simplifies further, with the coercing of $1, into

    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}
    '

-- 
Cheers, Ralph.

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