Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

While running Postfix on an Ubuntu, I have acquired a number of test email in an account usr1, and now I want to delete them before starting other testing. However, every time I try to delete using both d # and 'delete #`, nothing happens.

Example:

usr1@usr1:~$ mail  
"/var/mail/usr1": 5 messages 5 unread  
>U   1 usr2              Tue Apr 30 15:54  19/478   Testing local mail  
U   2 Mail Delivery Syst Tue Apr 30 15:54  78/2433  Undelivered Mail Returned to Sender
U   3 usr2               Tue Apr 30 15:55  19/614   Re: Testing local mail
U   4 usr2               Tue Apr 30 15:55  19/604   Re: Testing local mail
U   5 Mail Delivery Syst Tue Apr 30 15:55  73/2219  Undelivered Mail Returned to Sender
? d 1-5
? x

usr1@usr1:~$ mail
"/var/mail/usr1": 5 messages 5 unread
>U   1 usr2              Tue Apr 30 15:54  19/478   Testing local mail
U   2 Mail Delivery Syst Tue Apr 30 15:54  78/2433  Undelivered Mail Returned to Sender
U   3 usr2               Tue Apr 30 15:55  19/614   Re: Testing local mail
U   4 usr2               Tue Apr 30 15:55  19/604   Re: Testing local mail
U   5 Mail Delivery Syst Tue Apr 30 15:55  73/2219  Undelivered Mail Returned to Sender
? x

Can anyone explain why this is? Another Unix SE post talks about using the command as I'd expect it to work (granted, in Solaris), but I don't understand why those mails refuse to delete.

share|improve this question
1  
The answer is to exit from mail using quit or q instead of exit or x. Full answer once SE lets me answer my own. –  IanL May 2 '13 at 20:10

1 Answer 1

up vote 4 down vote accepted

After much digging, I realized that the problem was that I always exited from mail using either exit or x. From the Ubuntu man page:

exit (ex or x) Effects an immediate return to the shell without modifying 
               the user's system mailbox, his mbox file, or his edit
               file in -f.

So if you're trying to delete your emails and you use d * or d 1-5, etc, you need to make sure you leave mail using either quit or q.

I hope this saves someone else my confusion.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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