King0770-Notes: Difference between revisions
(Removing all content from page) |
No edit summary |
||
Line 1: | Line 1: | ||
=Removing Messages with Zmmailbox based on the Subject= | |||
<code><pre> | |||
#!/bin/bash | |||
# rm_message.sh user@domain.com subject | |||
if [ -z "$2" ]; then | |||
echo "usage: rm_message.sh user@domain.com <subject>" | |||
exit 0 | |||
else | |||
addr=$1 | |||
subject=$2 | |||
echo "Searching $addr for Subject: $subject" | |||
for msg in `zmmailbox -z -m "$addr" s -l 999 -t message "subject:$subject"|awk '{ if (NR!=1) {print}}' | grep -v -e Id -e "-" -e "^$" | awk '{ print $2 }'` | |||
do | |||
echo "Removing "$msg"" | |||
zmmailbox -z -m $1 dm $msg | |||
done | |||
fi | |||
</pre></code> | |||
Copy/Paste the script into a file, call it what you want, something like, "rm_message.sh". The syntax using the script would be something like: | |||
<code><pre>./rm_message.sh user@domain.com subjectName</pre></code> | |||
If the subject contains more than one word, put double quotes around the subject. | |||
<code><pre>./rm_message.sh user@domain.com "Hello World"</pre></code> | |||
Special thanks to Matt Fox. |
Revision as of 23:47, 2 July 2008
Removing Messages with Zmmailbox based on the Subject
#!/bin/bash
# rm_message.sh user@domain.com subject
if [ -z "$2" ]; then
echo "usage: rm_message.sh user@domain.com <subject>"
exit 0
else
addr=$1
subject=$2
echo "Searching $addr for Subject: $subject"
for msg in `zmmailbox -z -m "$addr" s -l 999 -t message "subject:$subject"|awk '{ if (NR!=1) {print}}' | grep -v -e Id -e "-" -e "^$" | awk '{ print $2 }'`
do
echo "Removing "$msg""
zmmailbox -z -m $1 dm $msg
done
fi
Copy/Paste the script into a file, call it what you want, something like, "rm_message.sh". The syntax using the script would be something like:
./rm_message.sh user@domain.com subjectName
If the subject contains more than one word, put double quotes around the subject.
./rm_message.sh user@domain.com "Hello World"
Special thanks to Matt Fox.