I am trying to filter out lines from server log files based on keywords like error, exception etc and color them.
perl -ne 'print if s/e-business|exception|environment|error/\033[1;31m$&\033[0m/gi'
It's been working right so far, but the issue is there is one specific error that I want to ignore. Let's say keyword TEST
, I can negate it but this line also contains error, exception keywords. I have tried lookahead and lookbehind but the problem is error, exception, TEST
do not come at fixed places.
So, how can I go about ignoring lines containing TEST
(don't go on case), even if it contains other keywords that I want ?
Note: I have done it in grep already, but I am interested to accomplish it in perl.