nmh-workers
[Top] [All Lists]

Re: One-liner to retrieve an email's recipients?

2020-08-18 12:23:22
Hi Conrad,

scan -format "%{to} %{cc}" -width 1000

These days, -width can take 0 to mean infinite.

Some more examples to study.

    $ cat 1 
    to: Foo Bar <foo@bar.example.com>, xyzzy@example.com
    cc: Xyzzy <xyzzy2@example.com>
    resent-to: postmaster@example.com
    resent-cc: abuse@example.com
    $
    $ scan -width 0 -forma '%{to} : %{cc} : %{resent-to} : %{resent-cc}' +$PWD
    Foo Bar <foo@bar.example.com>, xyzzy@example.com : Xyzzy 
<xyzzy2@example.com> : postmaster@example.com : abuse@example.com
    $
    $ scan -width 0 -forma '%(addr{to}) : %(addr{cc}) : %(addr{resent-to}) : 
%(addr{resent-cc})' +$PWD
    foo@bar.example.com : xyzzy2@example.com : postmaster@example.com : 
abuse@example.com
    $
    $ scan -width 0 -forma '%{to} : %{cc} : %{resent-to} : %{resent-cc}' +$PWD |
    > grep -Eo '[^ <]+@[^> ]+' |
    > sort -u
    abuse@example.com
    foo@bar.example.com
    postmaster@example.com
    xyzzy2@example.com
    xyzzy@example.com
    $

-- 
Cheers, Ralph.

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