I am not trying to remove all the mails.

I googled for mark all mail as read, actually got posts saying how to delete them instead.

I found out using echo p | mail will output first of unread then mark it read, but if I do this, I have to loop through them.

I figured for all read mails, they will be appended to a file named mbox

What I am trying to do is...I want to create a bash file which is then used for crontab that let's say, at the end of each month, change the name of mbox into month-year in this way I can keep track and organize the mails BUT in order to have the mails appended into mbox is reading the mails one by one first.

Am I thinking this in a wrong direction? Or can someone give me some advices?

Thanks in advance for any help

EDIT: I am just using sudo apt install mailutils for my ubuntu server

  • @dessert edited, that's the only thing I installed
    – Dora
    Commented Jan 10, 2018 at 22:18
  • You have to find or modify a script , example - aoakley.com/articles/2009-01-11-markallread.php . Please read the comments in the script and adjust accordingly.
    – Panther
    Commented Jan 11, 2018 at 1:27
  • @Panther thx thx, I will give that a try soon :D thx thx for the reference t hough ^_^
    – Dora
    Commented Jan 11, 2018 at 21:35

3 Answers 3


I was able to do it as follows:

  1. Type mail, it tell me how many unread messages I have. Let's say, 31.
  2. Type t 1-31, it displays all messages from 1 to 31 in a big concatenated sheet (turned out that t * achieves the same result, thanks to Jaime Hablutzel)
  3. Type q to quit view mode, type q again to quit mail

That's it! mail says all 31 messages saved in your mbox file, and next time you enter it, it will say "no mail for you".

  • 3
    this should be the accepted answer. Commented Jun 4, 2020 at 7:01
  • 2
    This works perfectly on the macOS mail utility as well
    – Jay Dorsey
    Commented Oct 8, 2020 at 17:47
  • 3
    Isn't t * more straightforward?. Commented Mar 24, 2021 at 18:16
  • It is :) I just didn't know of this possibility - thanks for the hint! Commented Mar 27, 2021 at 16:56
  • 2
    In my case I wanted to delete all the mail messages. For this, all you need to do is: 1) type mail; 2) d *; 3) q Commented Sep 28, 2021 at 12:14

A minor improvement on Vlad's answer. If you are not interested in the content and just want to mark the mails read, the follow command is more efficient: top :u. The command "top" shows only the first few lines of the message and :u gives just unread messages.


From the man page for mail:


Takes a message list and marks all messages as having been read.

Therefore in mail;

? seen *

will mark all messages read without removing them.

Although it appears ubuntu mail doesn't have this command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .