Koozali.org: home of the SME Server
Obsolete Releases => SME Server 7.x => Topic started by: tias_ on September 03, 2007, 03:57:38 PM
-
Hi, I have a question about erasing multiple mails. My account contains a large number of mail which I want to sort out. What I hope I can do is to have Linux command that deletes every mail that contains certain words in the subject.
So the question is, do someone know how to solve this from a shell?
Best regards,
//Tias
-
Don't know about the shell, but you could use Thunderbird and set up your account via imap. There is a search box in thunderbird that will easily show all your messages that match your criteria. Then delete them and they will also be deleted on the server.
-
tried that but Thunderbird are not that happy with the mission. We talk about thousands of mail.
A clean up process.
-
I have no tryed this... so be cautelous!
cd /<your_full_of_email_directory>
find <something_to_find> -exec rm -f {} \;
PLEASE... teste it with a minor search <something_to_find> first... and BE SURE TO BE ON RIGHT DIRECTORY!
-
Find only works on the names, so something like:
rm -f `find . -exec grep -l SearchWord {} \; `
but to be sure, just test with
find . -exec grep -l SearchWord {} \;
That should give the names of the files you would want to delete. (tested this)
Of course, if you do this wrong you could break the system, so make a backup first. Check the directory where you execute this command.
-
but to be sure, just test with
find . -exec grep -l SearchWord {} \;
That should give the names of the files you would want to delete. (tested this)
That is a very slow way to do it. Use 'grep -r ..." instead, and grep will only be started once, not once per email message.
grep -r -l 'Subject:.*text you are looking for' Maildir/cur
will list the filenames of each of the messages you want to remove.
grep -r -l 'Subject:.*text you are looking for' Maildir/cur | xargs rm -f
will remove all those messages.
Don't blame me if you try this and it doesn't do exactly what you want it to do. :-)
-
Well, I might have to drop a post here so I don't get too much tips. Probably would have solved my problem, some how it managed it self. Thunderbird must have worked for most of the mails through imap. After that pop3 started to work and I simply downloaded the rest.
Thanx for your advice, even though I didn't use them. But learned a little bit more about grep :-)