Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Just to be clear, the question is not about accessing archives of emails, but finding email related files mixed into a file archive "randomly" with lots and lots of other files; which is to say, right now my focus is on finding the files, then I'll figure out what to do with them.

Ways I've thought of so far are:

  • Searching the ascii text of a file for "from", then manually review the results,
  • Create a list of all possible email clients during the date range of files present, then create a list of known extension for those clients, search for those extensions, and manually review the results,
  • I don't know, seems like there might be a much easier way to do this, which is why I'm asking.
share|improve this question
    
It wouldn't hurt to find some way to consolidate all old email into a single client. I managed to get old archives into Gmail once. That makes it easier to search. –  William Jackson Mar 7 '12 at 14:14
    
@William Jackson: Just to be clear, the question is not about accessing archives of emails, but finding email related files mixed into a file archive "randomly" with lots and lots of other files; which is to say, right now my focus is on finding the files, then I'll figure out what to do with them. Am I misunderstanding your comment, or is my question not clear? Thanks! –  blunders Mar 7 '12 at 14:18
    
I misunderstood your question. Thank you for the clarification! –  William Jackson Mar 7 '12 at 14:20

1 Answer 1

up vote 1 down vote accepted

You can grep for all files containing the words To:, From: and Subject: at the beginning of a line, which should cover pretty much all emails:

find . -type f -print0 \
  | xargs -0    grep -l '^To:'          \
  | xargs -I{}  grep -l '^From:'    '{}' \
  | xargs -I{}  grep -l '^Subject:' '{}'

This outputs a list of files recursively, starting from the current directory.

share|improve this answer
    
+1 @Marco: Makes sense, and at least in the Outlook files I just reviewed in ascii text your approach would work. Do you have experience looking for emails, and if so, is it very uncommon to store the (To,From,Subject) part of the email in binary text; meaning for example, though the Outlook "msg" files were in binary, the (To,From,Subject) were in ascii. Also, while I've used grep a little before, it's not clear to me why the command for "To" is different than the command for "From" and "Subject". Thanks! –  blunders Mar 7 '12 at 14:58
1  
@blunders: I don't use Outlook, I use the maildir format which stores the mails in plain text. Applications like this makes you dislike binary (especially proprietary) formats. The grep commands are all the same, what differs is the call of xargs: The first one uses ”null” characters (because of the -print0), the -I{} substitutes the braces present in the command line with the arguments. That means grep will receive the arguments, not the braces. –  Marco Mar 7 '12 at 15:16
    
+1 @Marco: Selecting your answer as the answer, since suggesting to filter based on the text following a line-break was a great idea. In my case, after I parsed a few 1000 docs, I decided to change (To:,From,Subject) to (To:,From:,Subject:), since I was getting oddly a lot of false positives; also, made the search not case sensitive. As for Outlook, point of the question is how to find "any" emails, just not ones from a target format; meaning after I find the "all" the email, then I'll figure out the format they are in, and what to do with them. Again, thanks! –  blunders Mar 7 '12 at 17:18

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.