Link to home
Start Free TrialLog in
Avatar of clemend
clemend

asked on

How to delete mail I got?

How can I  delete mail after reading , which is very very long?
ASKER CERTIFIED SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Prefer this one (looks safer to me):

/ # >/var/mail/<username>

This will empty the user's mailbox.

or edit the mailfile with vi, and delete eg 500 lines with "d500".
Avatar of tel2
Or, if you want to delete say message numbers 5 to 600, type:
  d5-600
at mail's "?" prompt.
clemend, it would help if you told us which Unix you use, plus which mail
reader...

Assuming it's the "mail" command:
If you have lots of messages, some of which you want to keep, you can list just the headers by using "mail -h" (On AIX "mail -H", but AIX displays just the headers by default). From the list, you can select which messages to delete.

Typing "?" at the mail "?" prompt will bring up the help screen. The command "man mail" will tell you more about the command line options.


If you want to empty the whole mail file, /var/mail is the right directory for Solaris & HP-UX; On AIX it's /var/spool/mail; On further thought, you can just delete your mail file - it gets recreated correctly the next time you get mail.

paulqna, the mail file must start with a valid "From " line on Solaris, so after deleting e.g 500 lines, you should do "d/From " - Note the space after the word "From", to distinguish it from "From:" :)

tel2, AIX obviously has a more flexible mail client than the basic Solaris 2.7 client, which doesn't allow you to specify a range :(