Searching mail archives

Denis Beauchemin Denis.Beauchemin at USherbrooke.ca
Thu Jan 17 15:35:21 GMT 2008


Julian Field a écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Dave C wrote:
>   
>> Nigel Kendrick wrote:
>>     
>>> Hi,
>>>
>>> I need to search a months-worth of mail archives
>>> (/var/spool/MailScanner/archive/200611**) for a specific sender, 
>>> subject and
>>> attachment. I have had a play with grep and awk but I am not doing very
>>> well!!
>>>
>>> Are there any utilities to help or can anyone suggest a sensible command
>>> line that will do the job?
>>>
>>> Thanks
>>>
>>> Nigel Kendrick
>>>
>>>       
>> This works pretty good for me.. (watch the word wrap and the 
>> searchterm needs to be in single quotes)
>>
>> find /var/spool/MailScanner/archive/200611?? -type f -name df\* -exec 
>> grep -il 'searchterm' {} \; 
>>     
> What is enormously faster is
> find /var/spool/MailScanner/archive/200611?? -type f -name df\* -print | 
> xargs grep -il 'searchterm'
>
> Jules
>
>   
If you are using Linux, grep can do recursive searches by itself:
       -R, -r, --recursive
              Read all files under each directory, recursively; this  
is  equiva-
              lent to the -d recurse option.

So, "cd /var/spool/MailScanner/archive/200611?? && grep -ril 
'searchterm' $PWD" should also do it.

Denis

-- 
   _
  °v°   Denis Beauchemin, analyste
 /(_)\  Université de Sherbrooke, S.T.I.
  ^ ^   T: 819.821.8000x62252 F: 819.821.8045




More information about the MailScanner mailing list