如何删除 Solaris 中的所有邮件

如何删除 Solaris 中的所有邮件

我的 solaris 账户里有很多邮件

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

你知道怎样用 1 个命令行而不是逐行删除它们吗?

答案1

rm /var/mail/${user}

答案2

mailx 还有更多功能,包括批量删除消息。

使用 d 表示删除子命令,使用 h 显示邮箱中的邮件头。

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

答案3

不确定 solaris 邮件是否与 Linux 下的邮件相同,现在无法测试,但在 Linux 中,您可以d 102-107在邮件提示符下发出命令(如果输入 ,则会得到帮助页面?)。

答案4

两个命令就可以吗?

!>/var/mail/icinga
q

相关内容