Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have bunch of mails in my solaris account

107 letters found in /var/mail/icinga, 1 scheduled for deletion, 0 newly arrived
  107  d  2886   MAILER-DAEMON  Fri Jun 11 00:39:39 2010
> 106     2895   MAILER-DAEMON  Fri Jun 11 00:13:02 2010
  105     2890   MAILER-DAEMON  Fri Jun 11 00:10:05 2010
  104     2888   MAILER-DAEMON  Tue May 18 15:13:34 2010
  103     2874   MAILER-DAEMON  Tue May 18 14:58:29 2010
  102     2874   MAILER-DAEMON  Tue May 18 14:28:34 2010

Any idea how can i delete all of them with 1 command line instead of line by line?

share|improve this question
    
Which mail program? All Solaris releases include mail (not so user friendly) and mailx (slightly more user friendly). Many sites / newer releases also install much more user friendly & powerful command line mail readers such as mutt, elm, and pine (plus of course Thunderbird and Evolution at sites running it as a desktop). –  alanc Nov 30 '10 at 4:13

5 Answers 5

Not sure if solaris mail is the same as under Linux and can't test right now, but in Linux you would issue the command d 102-107 at the mail prompt (and get a help page if you enter ?).

share|improve this answer
    
it returns 'Illegal numeric' –  conandor Nov 30 '10 at 2:54
2  
Maybe because 107 is already marked as deleted? Try d 102-106 and see man mail. –  Sven Nov 30 '10 at 3:01
rm /var/mail/${user}
share|improve this answer

I'm not sure if this works on Solaris (it does under FreeBSD which is mailx afaik), but try d * inside the mail client.

share|improve this answer

mailx has many more features, including batch deleting messages.

use d for the delete subcommand and h to show the headers of messages in the mailbox.

mailx
mailx version 5.0  Type ? for help.


"/var/mail//myuser": 11 messages: 11 new

>N  1 My User        Wed Mar 28 17:50   27/1073  Output from "cron" comman
 N  2 My User        Wed Mar 28 18:56 3226/253350 Output from "cron" comman
 N  3 My User        Wed Mar 28 21:17   24/896   Output from "cron" comman
 N  4 My User        Thu Mar 29 21:17   24/896   Output from "cron" comman
 N  5 My User        Fri Mar 30 17:50   27/1073  Output from "cron" comman
 N  6 My User        Fri Mar 30 18:56 3226/253347 Output from "cron" comman
 N  7 My User        Fri Mar 30 21:17   24/896   Output from "cron" comman
 N  8 My User        Sun Apr  1 21:18   24/896   Output from "cron" comman
 N  9 My User        Mon Apr  2 17:50   27/1070  Output from "cron" comman
 N 10 My User        Mon Apr  2 18:56 3226/253344 Output from "cron" comman
 N 11 My User        Mon Apr  2 21:17   24/893   Output from "cron" comman
> ? d 1-11
> ? h
No applicable messages
? q
share|improve this answer

Will two commands do?

!>/var/mail/icinga
q
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.