use formail to get last email of an email file

266 views Asked by At

I would like to get the last email of an email file.

I found question that splits emails: How to split mailbox into single file per message?

But I would like something more efficient.

Ideally, I would like to get the message id of the last email. For one email, one can simply do:

formail -czxMessage-ID:
1

There are 1 answers

0
Sato Katsura On BEST ANSWER

You can do it like this:

formail -s formail -czx Message-Id: <mailbox | tail -1

This is probably not very efficient. However, more efficient methods are likely to be a lot more complicated.