DeutschEnglish

Submenu

 - - - By CrazyStat - - -

20. March 2015

Remove duplicate mails from a maildir

Filed under: Linux,Server Administration — Tags: , , , , — Christopher Kramer @ 19:30

In case somehow, you got duplicate mails in a maildir, like me, maybe this is helpful to you:

find /var/mail/user -type d -name cur -print0 | xargs -0 /usr/bin/fdupes -n | less

Of course you need fdupes installed. On debian:

apt-get install fdupes

The above command is the dry run, showing you the duplicates.

Then to delete the duplicates, leaving only the first found file:

find /var/mail/user -type d -name cur -print0 | xargs -0 /usr/bin/fdupes -ndN | less

Use the same thing again with “new” instead of “cur” if you have duplicate unread mails. This only looks at duplicates within the same folder, so you can also safely run it on /var/mail for all users.

Note that this assumes the duplicates have exactly the same content. If you want to clean duplicates which are a bit different, consider this tool.

Update 2018: Three years later, I had the same problem, googled it and found my own blog post 😉 And it again solved the problem 🙂

Recommendation

Try my Open Source PHP visitor analytics script CrazyStat.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment