Skip to main content

tail f with highlighting

tail f with highlighting


If you want to highlight something when doing �tail -f� you can use the following command:
tail -f /var/log/logfile | perl -p -e s/(something)/33[7;1m$133[0m/g;
or if your terminal supports colours, e.g. linux terminal, you can use this:
tail -f /var/log/logfile | perl -p -e s/(something)/33[46;1m$133[0m/g;
If you need to highlight multiple words you can use something like this:
tail -f /var/log/logfile | perl -p -e s/ (something|something_else) /33[46;1m$133[0m/g;
and if you want it to beep on a match use this:
tail -f /var/log/logfile | perl -p -e s/(something)/33[46;1m$133[0m07/g;
If you find that perl is too heavy for this you can use sed:
tail -f /var/log/logfile | sed "s/(something)/x1b[46;1m1x1b[0m/g"
Note, that in the last example you have to actually type �cntl-v cntl-[� in place of �^[�
x1b character can also be used as the escape character.

For the full list of control characters on Linux you can look at:
man console_codes

download file now

Popular posts from this blog

Takenoko I LOVE This Game!

Takenoko I LOVE This Game! My Husband bought me the Collectors Edition of Takenoko and when I first saw it, I immediately thought: ok this is definitely a girly game made to entertain young children. However, Takenoko turned out to be a fantastic game! Ive even put it in my �top five" games list. Its a game meant for 2-4 players and is recommended for ages 13 and up, yet my Husband and I had no problems playing this with our kids who are 11 and 12. The box says it plays in about 45 minutes, but weve found most games take about 60 if playing with 4 people --youll be having so much fun, time wont matter anyways! The backstory of Takenoko is written in a comic book style inside the rulebook. Its a super cute game where a Chinese Emperor whom has a large garden --grows a wide selection of bamboo plants, maintained by his Gardener. However the Emperor has now received a present - a large panda bear which he lets roam around in his garden. Unfortunately the panda has quite the appetit...

Top 3 ways to disable high contrast and accessibility features in Windows 7

Top 3 ways to disable high contrast and accessibility features in Windows 7 BEFORE FOLLOWING THIS GUIDE, make sure your users dont actually need this feature. High-contrast mode is very useful for some people. If you disable it for them, they will be pissed (I noticed several visitors got mad at me for writing this tutorial). Working as a system administrator (among other roles) in an international school, weve got a lot of computers to manage here and kids never miss a chance to mess up with them. The latest trend is to enable high-contrast mode, basically making the computer turn black and white along with a bunch of other fluorescent colors. I dont need to remind you how annoying this is and why a more permanent solution needs to be found for this problem. Tip: you can quickly enable or disable high contrast mode by pressing  Left Alt+Left Shift+Print Screen . In this article, I am providing three different ways to permanently disable high-contrast mode . All have their pros an...