Re: [exim] search exim logs with input file, maybe csv ?

Top Page
Delete this message
Reply to this message
Author: Jan Ingvoldstad
Date:  
To: exim users
Subject: Re: [exim] search exim logs with input file, maybe csv ?
On Fri, Mar 20, 2015 at 7:26 PM, Jeremy Harris <jgh@???> wrote:

> On 19/03/15 19:07, Marc Baasten wrote:
>
>> Hello all,
>>
>> I have to look up allot of e-mail addresses in the log files, is it
>> possible to feed exigrep with a input file ( maybe csv style ) with these
>> e-mail addresses
>> and have the output exported to a file.
>>
>
> Sounds like a simple shell loop to me, calling exigrep
>
>>
>> Or is possible to do this with a different tool than exigrep which leaves
>> the exim format intact ?
>>
>
> ... or just grep.
>
>
> while read foo
> do
> egrep "$foo" mainlog >> output_file
> done < file_with_names



This has a risk of unintended side effects if you don't want to treat
e-mail addresses as regexps.

Don't use egrep unless you _really_ mean to use regexps.

I think it's better to use grep's built-in file-reading thing, specifying
fixed-string matching, instead:

grep -Ff file_with_names mainlog > output_file

If file_with_names contains regexps, and they're Perl compatible (which
they most likely are, right?), GNU grep offers the following trick:

grep -Pf file_with_regexps mainlog > output_file

--
Jan