Mail cleanup from ksh script, keeping 50 most recent msgs

I found some posts describing how to completely clean out a mailbox in Unix/Linux. But I want to keep the 50 most recent messages. Any ideas out there?

Thanks!

What format is your mailbox?

Mbox? Maildir? Or something completely different?

mbox.

For example, if I have 3 messages in my system mailbox, and I read one and exit mailx, I see these messages:

Saved 1 message in /home/users/tiger/mbox
Held 2 messages in /var/spool/mail/tiger

I would like to clean up /var/spool/mail/tiger (leaving most recent 50 messages) without putting anything in /home/users/tiger/mbox. Alternatively, I could completely clean out /var/spool/mail/tiger and put the 50 most recent messages into /home/users/tiger/mbox.

Whichever is easier, I'm not choosy.

Thanks for your time and assistance.