0

I just found a huge list of emails under my user account in Centos /home/user/mail/new

I opened some of them and noticed they were sent from a particular cron job. From address is [email protected]. I need to find out if all these emails were sent by [email protected] - It's about 30GBs of email. Is there a way to grep out a list of unique list of From addresses? The format of the email is something like this:

Return-path:

Envelope-to: [email protected]

Delivery-date: Thu, 11 Aug 2011 04:34:02 -0400

Received: from user by hostname.com with local (Exim 4.69)

(envelope-from )

id 1QrQiI-0004qM-6V

for [email protected]; Thu, 11 Aug 2011 04:34:02 -0400

From: [email protected] (Cron Daemon)

To: [email protected]

Subject: Cron /opt/gsn/reports/pr.sh

Content-Type: text/plain; charset=UTF-8

Auto-Submitted: auto-generated

Message-Id:

Date: Thu, 11 Aug 2011 04:34:02 -0400

[MESSAGE CONTENT]

3 Answers 3

3
$ grep -E '^From:' /some/file | uniq
3
  • -bash: /bin/grep: Argument list too long - what can I do about this?
    – gAMBOOKa
    Nov 21, 2011 at 6:53
  • Use split to split the source file up into chunks.
    – dmourati
    Nov 21, 2011 at 7:07
  • It's not one file, each email is about 20K, and the total emails amount to 30G.
    – gAMBOOKa
    Nov 21, 2011 at 7:09
1

To get total number of emails, run:

grep From: /home/user/mail/new | wc -l

to get the count of emails from root, run this

grep ^From /home/user/mail/new | grep root\@hostname.com | wc -l

now (Total emails) - (emails from root) = actual number of emails from total emails.

0

Try this:

awk '/^From: / { print $2 }' /home/user/mail/new | sort | uniq -c | sort -rn

It's not one file, each email is about 20K, and the total emails amount to 30G.

awk '/^From: / { print $2 }' /home/user/mail/* | sort | uniq -c | sort -rn

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .