DAve wrote:
I would love to have a way to tail a log, like piping to grep, except I see every line and the lines I would normally grep for are highlighted. That would be cool. Anyone know of a bash command or tool that will do this?

Side note, I am tailing sendmail after changes to my outbound queue runners. I want to highlight my sm-mta-out lines but still see all lines.

A little late to the party now, but the following Perl script will 'highlight' the lines containing $pattern with a blank line above and below, surrounded by ****. The lines not matching will be printed normally. Note, File::Tail must be installed:

#!/usr/bin/perl
# grep.pl

use warnings;
use strict;
use File::Tail;

my $pattern = "submission";
my $log = "/var/log/maillog";
my $ref=tie *FH,"File::Tail",(name=>$log, maxinterval=>3);

while (<FH>) {

        if ($_ =~ /$pattern/) {
                chop ($_);
                print "\n**** $_ ****\n\n";
        } else {
                print "$_";
        }
}


pearl# ./grep.pl

**** Aug 22 11:30:45 pearl vpopmail[65893]: vchkpw-submission: (CRAM-MD5) login success [EMAIL PROTECTED]:2607_f118__5 ****

Aug 22 11:31:19 pearl spamd[32860]: spamd: connection from localhost [127.0.0.1] at port 57092 Aug 22 11:31:19 pearl spamd[32860]: spamd: processing message <6e3e383b080822071 [EMAIL PROTECTED]> for [EMAIL PROTECTED]:58


**** Aug 22 11:31:46 pearl vpopmail[66048]: vchkpw-submission: (CRAM-MD5) login success [EMAIL PROTECTED]:2607_f118__5 ****

Aug 22 11:31:56 pearl spamd[95770]: prefork: child states: II

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to