On Thursday 04 September 2008, Amos Shapira wrote: > 2008/9/4 Amos Shapira <[EMAIL PROTECTED]>: > > 2008/9/4 Maxim Veksler <[EMAIL PROTECTED]>: > >> That would actually be great and is exactly the kind of solution I'm > >> searching for. The only problem with the grep --color apporoach is > >> that It would only show me the lines that contain the search term. I > >> want to see the whole scrolling log and highlight what interested me. > > Also, a quick CPAN search turned up > http://search.cpan.org/~rra/ANSIColor-1.12/ANSIColor.pm > If you are a Perl programmer, I'd reckon a 15 minute work will get you > what you want (but I don't have them right now to do this for you, > sorry).
Here's a Proof-of-Concept script I wrote to implement this: <<<<<<<<<<<< #!/usr/bin/perl # Written by Shlomi Fish - http://www.shlomifish.org/ - 2008 # Licensed under the MIT/X11 License. # # Example: # perl color-patterns.pl --pat hello=red --pat '(?i:maxim)'=blue use strict; use warnings; use Getopt::Long; use Term::ANSIColor; my %patterns; GetOptions("pat=s" => \%patterns); my @p; while (my ($k, $v) = each (%patterns)) { push @p, { pat => qr{$k}, color => $v }; } while (my $l = <>) { foreach my $pat (@p) { my $re = $pat->{pat}; my $c = $pat->{color}; $l =~ s/($re)/colored($1, $c)/eg; } print $l; } >>>>>>>>>>>>>>>> Regards, Shlomi Fish ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Why I Love Perl - http://xrl.us/bjn88 Shlomi, so what are you working on? Working on a new wiki about unit testing fortunes in freecell? -- Ran Eilam ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]