On Saturday 30 August 2003 03:02, Marshal Newrock wrote:
> It's been a little while since I've done something like this, but I think
> I've got it.  'cat /dev/stdin' is the wrong way to read input to a
> command.  Also, I'd just save everything in a variable, and avoid disk
> access.  And make sure you're only sending the header.  I believe there's
> an 'h' flag for procmail to do this.  Scanning every line of a 5MB email
> will be a bit of a performance loss.
>
> #!/bin/bash
> notify_msg=""
> while read header_line
> do
>     if `echo $header_line | egrep -q '^(From|Date|Subject)'`
>     then
>         notify_msg="${notify_msg}${header_line}\n"
>     fi
> done
> echo -e $notify_msg | mail -s "Mail Notification" $1
>

This script is beautiful! Is helping me on my way to becoming more than a 
mediocre bash 'programmer'. Thanks very much.

> If you don't understand the grep line, read the entire grep man page top
> to bottom.  It will be one of the more useful things you do.

The grep line is fairly easy to understand. I've got to learn regular 
expressions, though. They seem too useful!

Regards,
Jason

--
[EMAIL PROTECTED] mailing list

Reply via email to