[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Grep only mail headers via STDIN?



On Fri, Mar 05, 2004 at 10:37:01AM +0100, Jens Benecke wrote:
> Hi,
> 
> I want to create a script that greps for a specific mail header coming from
> STDIN. "mailgrep" and "mboxgrep" don't work, they need files to work on,
> but the mail comes via STDIN.
> 
> So I need to write something like
> 
> | condredirect spam@mydomain.lan egrep "^X-Spam-Flag: YES" 
> 
> BUT where grep would "exit 1;" and not search any further when it encounters
> the first empty line (the end of the mail headers)

So you're only filtering single emails, not whole mboxes, and you only
want to grep the headers? Stick

  sed -n -e '1,/^$/p'
  
in the pipe before the grep. That'll pass through everything up to the
first empty line and then stop.  

-- 
Pigeon

Be kind to pigeons
Get my GPG key here: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F

Attachment: pgpHb1qsrnnOS.pgp
Description: PGP signature


Reply to: