Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Due to some bad cron jobs I now have ~1600 mail messages, most of them containing the same error log. I would like to quickly group them by subject and delete them, while limiting the chances of missing some important message.

I couldn't figure out a way to do anything using the mail command other than deleting each message individually. I tried installing pine, but it seems that even there I have to go over each message individually and hit the D key.

Surely there's a way to script this. Right?

I'm using ubuntu server 10.04.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Mutt is really good at this. You could tag-pattern (shift-T) on the common subject string, then tag-prefix (;) delete (d) the matching messages.

"Mutt Manual, Using Tags"

share|improve this answer
add comment

If your mails are in a Maildir (like e.g. ~/Maildir/cur) you can just use grep and rm:

grep -l "Subject: My error log message" ~/Maildir/cur/* | xargs rm

if instead they are in a mbox this of course doesn't work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.