Era Eriksson suggested to Dan Hersam,
| Here's an alternative approach, if you have tac(1) and a tail(1) that
| understands the +n argument -- strip the last four lines from +all+
| mail (-:
|
| :0fwb
| | tac | tail +5 | tac
Youch.
BOTTOMLINES=4
:0Bbfwi
* 1^1 ^.*$
* $ -$BOTTOMLINES^0
# The following condition might be needed for adjustment; I haven't tested:
# * -1^0
| head -$= # if you don't have head(1), sed "$="q
| Any script that has to do something to the +last+ n lines of a message
| is tricky to write with standard line-oriented tools because they
| usually are based on the assumption that you want to do everything in
| one pass, from start to end. The tac(1) trick can obviously be useful
| for simplifying your sed scripts, too:
|
| :0fwb
| | tac | sed '1,/^-- $/d' | tac
Again, though the anything-but-a-sig-separator-regexp is messy,
:0B
* ^()\/-- $((.|..|[^-].*|.[^-].*|..[^ ].*)?$)*^^
{
SIGBLOCK=$MATCH
:0Bbfwi
* 1^1 ^.*$
* -1^1 SIGBLOCK ?? ^.*$
| head -$= # or sed "$="q
}
Ideally there should not be more than one signature separator, because the
whole idea of a separator is to say, "Everything below here is my
.signature." For mail like that,
:0Bbfwi
* ^-- $
* ! ^-- $(.*$)*-- $
| sed -ne '/^-- $/q' -e p
and if a message has more than one signature separator, shame on the sender.