nmh-workers
[Top] [All Lists]

Re: format and output all received: lines in an e-mail message

2019-11-20 08:00:56
Hi Greg,

That's all I've time for at the moment, but others may chip in and this
saves them covering some of the ground.

Ken's mhl(1) suggestion is what I would have tried.  But there's also
non-nmh solutions, e.g. sed or awk if you're familiar with those.
This prints all the Foo fields, each on a line, joining continuation lines.

    #! /usr/bin/gawk -bf

    BEGIN {
        IGNORECASE = 1
    }

    pending {
        if (/^[ \t]/) {
            printf " %s", $0
        } else {
            print ""
            pending = 0
        }
    }

    /^foo[ \t]*:/ {
        printf "%s:%s", FILENAME, $0
        pending = 1
        next
    }

    /^$/ {
        nextfile
    }

    END {
        if (pending)
            print ""
    }

-- 
Cheers, Ralph.


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