I have a whole lot of mail in my /var/mail/user file. Is there some way I can delete all the mail generated in 2016 only?

2 Answers 2


You can use mutt for this purpose. It is a small but very powerful text based program for reading and sending electronic mail:

sudo apt install mutt 

The steps are:

  • Run mutt in to a terminal.

  • Press Shift+D - delete-pattern - delete messages matching a pattern.

  • Type the pattern: ~d 01/01/2016-31/12/2016 and press Enter. You could use also the pattern ~d 1/16-12/16. Where ~d [MIN]-[MAX] means messages with “date-sent” in a Date range.

  • Press q and then hit Enter again.

enter image description here

Other useful patterns according to the current topic could be:

  • ~d>30d - will delete the messages older than 30 days.
  • ~m 120-234 - will delete the messages with numbers in the range 123 to 234.


  • 1
    The pattern is ~d>30d no spaces.
    – Martin T.
    Nov 9, 2020 at 8:32
  • Hi, @MartinT. Thanks for the comment. Probably at the version I've made the tests 3 years earlier the syntax was with spaces. However, if you find this answer useful, don't forgot to upvote.
    – pa4080
    Nov 9, 2020 at 10:39

You might be able to use procmail to generate a new file. Normally you would file your mail as you work.

There are a number of email clients that you can use. Many allow you to select multiple messages to file or delete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.