Date: Fri, 22 Aug 2008 11:27:54 -0400 From: Steve Bertrand <steve@ibctech.ca> To: DAve <dave.list@pixelhammer.com> Cc: 'User Questions' <freebsd-questions@freebsd.org> Subject: Re: Tailing logs Message-ID: <48AEDAFA.1010905@ibctech.ca> In-Reply-To: <48AECD11.1000705@pixelhammer.com> References: <48AECD11.1000705@pixelhammer.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 steve@ibctech.ca: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 4g37a6ee4bu21e99ebc9e123ab7@mail.gmail.com> for iaccounts@ibctech.ca:58 **** Aug 22 11:31:46 pearl vpopmail[66048]: vchkpw-submission: (CRAM-MD5) login success steve@ibctech.ca:2607_f118__5 **** Aug 22 11:31:56 pearl spamd[95770]: prefork: child states: II
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48AEDAFA.1010905>