> On Aug 13, 2015, at 5:39 PM, Viktor Dukhovni <postfix-us...@dukhovni.org> 
> wrote:
> 
> On Wed, Aug 12, 2015 at 04:35:59AM -0600, @lbutlr wrote:
> 
>> I need to search the logs for outgoing mail that is coming from specific
>> users, but I'm having a hard time with this since the to and from are
>> logged on separate lines in the log
>> 
>> Does anyone have a grep solution that would show all the outbound emails
>> in the 30 days of logs for a specific user?
> 
>       # gunzip -fc $(ls -rt /var/log/maillog*) |
>           perl collate |
>           perl -ne '
>               BEGIN  { $/ = "\n\n"; $match = shift; }
>               print if m{\Q$match\E}io;
>               ' \
>           ": from=<sen...@example.com>”

Thank you, that worked perfectly (well, once I changed the command to bzcat, of 
course :)

I even made it into a bash function:

function mailgrep {
   bzcat $(ls -rt /var/log/maillog*) | perl /usr/local/bin/collate | perl -ne ' 
   BEGIN  { $/ = "\n\n"; $match = shift; } 
   print if m{\Q$match\E}io; 
   ' \
   ": from=<$*" | grep -v backup  | grep "to=<“


-- 
You start a conversation you can't even finish it
You're talkin' a lot, but you're not sayin' anything
When I have nothing to say, my lips are sealed
Say something once, why say it again?

Reply via email to