Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete all mail from command line

Status
Not open for further replies.

hcclnoodles

IS-IT--Management
Jun 3, 2004
123
GB
Hi sorry this is a real newbie question and i have looked at the man pages but cant seem to find what im looking for. I run the command `mail` from the command line, however, I have a server i havent looked at for a while with a ridiculously large amount of mails in there. i use the command `h a` to list all the headers and it scrolls up for ages. My question is, how can i delete all mails, ie empty the mailbox, I saw the command `d n` which deletes a given message number, but i need a command like `d all`

any help would be greatly appreciated
 
With AIX you can do a d 1-nn where nn is the number of the last message. HTH.
 
either 'd1-2765' (or however many mails you have) or if you have root got to wherever your system keeps the mail files /usr/spool/mail on AIX) and delte the whole file

Alex
 
On Solaris and Tru64, in mailx use: d 1-nn as already suggested in previous replies.

A really dirty way of doing it is to delete the mail file(s) (if you can find it/them):
On Solaris (as root):
ls -l /var/mail
rm -i /var/mail/<username>
ls -l /path/to/<username> # ie the home directory
rm -i /path/to/<username>/mbox # if it exists
On Compaq Tru64 (as root):
ls -l /var/spool/mail
rm -i /var/spool/mail/<username>
ls -l /path/to/<username> # ie the home directory
rm -i /path/to/<username>/mbox # if it exists

If further mail messages are sent to the <username> then the file will be re-created by the system.

I hope that helps.

Mike
 
Hmm, none of these work on SCO. I too have an old SCO box without the possibility to delete all mails in one go. d 1-99 or d [1-99] just gives me "illegal numeric". I don't know how to delete the mails from within 'mail', but on this SCO box, I generally delete the /var/mail/(username) file (why can't they keep the same structure as the rest of the world?).
So,
su - root
cd /var/mail
ls
(find the file corresponding to the user)
more (filename)
If these are indeed the mails you want to delete then,
rm (filename)
exit
 
You can try:
Code:
d *

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top