LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-31-2007, 11:10 AM   #1
asadmahmand
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Rep: Reputation: 0
Mail command usage


how can i delete New (with status N) root emails through command.
i think this should work but its not deleting them.
mail -u root
& d N

A response will be highly appreciated.

Last edited by asadmahmand; 10-31-2007 at 11:11 AM.
 
Old 10-31-2007, 01:41 PM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
Be sure you are logged in as root (or use the 'su' or 'sudo' commands). Otherwise you won't have permission to delete them. Use the 'q' command to quit mail when done, not 'x'.

Note that if the email is coming from cron, you tell cron to send the mail to a different address. In file /etc/crontab or the crontab listing, put this (use your real username):

MAILTO=asadmahmand
 
Old 11-01-2007, 06:01 AM   #3
asadmahmand
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Original Poster
Rep: Reputation: 0
thanks for the reply.
acctually my concern is that the command has the following santax.
& d [message numbers]
like

mail -u XX
& d 1 2 3
this will delete the following messages 1 2 and 3.
but i need to delete emails of a very big file of /var/spool/mail/XX
and i have to delete all new (N) or unread mails (U).

i have searched a lot but did not find any answer.
 
Old 11-01-2007, 06:42 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The classic mail command does not accept flags in "message list" so you can only specify number or ranges of numbers. However on my system I have mailx and it accepts expressions like
Code:
? d :n   # to delete all new messages
? d :u   # to delete all unread messages
and so on. An excerpt from the manual page:
Quote:
The following special message names exist:

:n All new messages.
: o All old messages (any not in state read or new).
:u All unread messages.
:d All deleted messages (for the undelete command).
:r All read messages.
:f All `flagged' messages.
:a All answered messages (cf. the markanswered variable).
:t All messages marked as draft.
:k All `killed' messages.
:j All messages classified as junk.
I hope this helps.
 
Old 11-01-2007, 10:51 AM   #5
asadmahmand
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Original Poster
Rep: Reputation: 0
thanks colucix.
your reply solved the problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail usage quota graph with postfix vm_devadas Linux - Software 6 09-20-2006 12:36 PM
Mail usage quota graph with postfix vm_devadas Linux - Software 2 09-12-2006 09:59 AM
CU Command Usage Help TankerKevo Linux - Hardware 0 12-29-2005 12:03 AM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 07:06 PM
rm command usage big_orange Linux - General 3 11-04-2003 05:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration