> > |->mailq | tail +2 | awk 'BEGIN { RS = "" } \
> > |-> / [EMAIL PROTECTED]/ { print $1 } \
> > |-> ' | tr -d '*!' | postsuper -d -
> Here is an even simpler one:
>
> mailq | awk '/[EMAIL PROTECTED]/ { print $1 }' | postsuper -d -
This is flawed.
We have domain hosting customers that forward their email to other
accounts elsewhere. Obviously AOL is one of these elsewheres because of
their size.
The mailq entry in this case is like this:
F2F5DD711E 1920 Sat Mar 13 04:10:39
[EMAIL PROTECTED]
(host mailin-04.mx.aol.com[205.188.157.25] said: 421 SERVICE NOT
AVAILABLE, TEMPORARY DNS FAILURE (in reply to MAIL FROM command))
[EMAIL PROTECTED]
That is from a real one. I just changed the user's name.
This user has three such messages sitting in the queue waiting to expire.
At times I want to clean these things up, especially if I am looking for
something specific in the queue, and want to weed out the unimportant
things first.
When using your script:
mailq | awk '/[EMAIL PROTECTED]/ { print $1 }' | postsuper -d -
postsuper: warning: invalid mail queue id: [EMAIL PROTECTED]
But when using the example from man postsuper:
mailq | tail +2 | awk 'BEGIN { RS = "" } /[EMAIL PROTECTED]/ { print $1 }
' | tr -d '*!' | postsuper -d -
postsuper: D05AFD713C: removed
postsuper: F2F5DD711E: removed
postsuper: B4D9DD7112: removed
postsuper: Deleted: 3 messages
Something else of note for people reading that may not be as familiar with
regexp:
In the example you will note they use / [EMAIL PROTECTED]/. There is a
reason for the " ".
Lets say you had [EMAIL PROTECTED] and [EMAIL PROTECTED], and you
wanted to kill queued files just for [EMAIL PROTECTED] If you forget the
space, you will kill both, because "[EMAIL PROTECTED]" matches
"[EMAIL PROTECTED]" and "[EMAIL PROTECTED]" but " [EMAIL PROTECTED]"
matches "[EMAIL PROTECTED]" without matching "[EMAIL PROTECTED]".
--Eric