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?
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:
muttin to a terminal.
Press Shift+D - delete-pattern - delete messages matching a pattern.
Type the pattern:
~d 01/01/2016-31/12/2016and 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.
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