Decoding email headers on your shell

To be able to move PEAR packages from php.net's svn server to a git repository, I needed to create a authors file containing the svn username, real name and email address of all committers.

Getting all usernames was quite easy with

 committers.txt]]>

but that was only half of the job - real names and email addresses were missing.

Luckily, I have a maildir structure with all of the cvs commits of the last 6 years. Extracting the From: lines is trivial with grep, but unfortunately they are encoded:

]]>

This lines are MIME encoded strings using the encoded-word syntax defined in RFC 2047.

I did not find any tools in my distribution that can decode them on CLI, but a web search for "RFC 2047 shell" did give me a mailing list question from 2005 without an answer, and finally an entry on freshmeat about conv2047 which does exactly what I need - take some standard input and decode it to UTF-8. Awesome!

Written by Christian Weiske.

Comments? Please send an e-mail.