1

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

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.

References:

| improve this answer | |
0

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.

| improve this answer | |

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.