问题原文
原帖链接 · TRiG · CC BY-SA 3.0
We have a lot of messages in the mail queue from a certain address. I want to delete the lot of them. I've found ways to delete by subject line, but I want to search by From address, and that seems to be a lot trickier. (Note: these are mainly outgoing messages.)
Some Googling has found me this command on HowToForge, but there's no explanation of what it does.
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
I was trying to use mailqueuemng, but didn't get very far (it doesn't have a --help, for one thing).
已采纳解答
原帖链接 · Dan Pritts · CC BY-SA 4.0
The pipeline can be analyzed step by step to see what it does. Try running each command in sequence until you understand them all:
postqueue -p
print the queue
postqueue -p | tail -n +2
get rid of the first couple lines
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }'
search for any lines with [email omitted]; print the first field of those lines.
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }' | tr -d '*!'
get rid of any *!
This will output a bunch of queue ids.
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
The final command tells postfix to delete those queue ids.
Read The Fine Man pages on postqueue, tail, tr, and postsuper. Awk is a more complicated, it's its own little language. you'll need a bit more than a man page to understand its complexity, although in my experience 99% of the awk usage is much like that particular one-liner.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
