tail with color? - Unix
This is a discussion on tail with color? - Unix ; I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail logs while testing. I was wondering if there is any tools similar that might have the ability to color keywords (maybe based on REs)? This would help certain ...
| | LinkBack | Tools |
|
#1
| |||
| |||
| logs while testing. I was wondering if there is any tools similar that might have the ability to color keywords (maybe based on REs)? This would help certain keywords stand out more. Or can the output be piped through another application that may be able to do it? -- Troy Piggins ,-o o ) Ubuntu linux 6.06 http://ubuntu.com RLU#415538 http://counter.li.org `-o uptime: 12:17:59 up 18 days,17:46,2 users,load average:0.00,0.00,0.00 |
|
#2
| |||
| |||
| * Troy Piggins > I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail > logs while testing. I was wondering if there is any tools > similar that might have the ability to color keywords (maybe > based on REs)? This would help certain keywords stand out more. > > Or can the output be piped through another application that may > be able to do it? tail -f file | perl -pe 's/keyword/\e[1;31;43m$&\e[0m/g' This only works on ANSI terminals, but all others have become virtually extinct. \e[...m ist the ANSI escape sequence SGR "select graphic rendition". The "..." can be replaced by some semicolon-separated integers, with the meaning: 0 : all attributes off 1 : bold 31 : foreground red 43 : background yellow "keyword", of course, can be any perl regular expression: (foo|bar) highlight the strings foo and bar \b((foo|bar)\b highlight the words foo and bar .*\b((foo|bar)\b.* highlight the whole line that contains the words foo or bar - Andi |
|
#3
| |||
| |||
| * Andreas Karrer wrote: > * Troy Piggins >> I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail >> logs while testing. I was wondering if there is any tools >> similar that might have the ability to color keywords (maybe >> based on REs)? This would help certain keywords stand out more. >> >> Or can the output be piped through another application that may >> be able to do it? > > tail -f file | perl -pe 's/keyword/\e[1;31;43m$&\e[0m/g' > > This only works on ANSI terminals, but all others have become virtually > extinct. \e[...m ist the ANSI escape sequence SGR "select graphic > rendition". The "..." can be replaced by some semicolon-separated > integers, with the meaning: > > 0 : all attributes off > 1 : bold > 31 : foreground red > 43 : background yellow > > "keyword", of course, can be any perl regular expression: > > (foo|bar) highlight the strings foo and bar > \b((foo|bar)\b highlight the words foo and bar > .*\b((foo|bar)\b.* highlight the whole line that contains the words foo or bar Wow - that's awesome! Thanks Andreas! -- Troy Piggins ,-o o ) Ubuntu linux 6.06 http://ubuntu.com RLU#415538 http://counter.li.org `-o uptime: 16:39:26 up 18 days,22:08,2 users,load average:0.00,0.00,0.00 |
|
#4
| |||
| |||
| Troy Piggins wrote: > I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail > logs while testing. I was wondering if there is any tools > similar that might have the ability to color keywords (maybe > based on REs)? This would help certain keywords stand out more. Type "less /var/log/mail.log". Then type "/foo", where "foo" is a regular expression matching whatever you want to highlight, and hit return. Now type "F". - Logan |
|
#5
| |||
| |||
| * Logan Shaw wrote: > Troy Piggins wrote: >> I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail >> logs while testing. I was wondering if there is any tools >> similar that might have the ability to color keywords (maybe >> based on REs)? This would help certain keywords stand out more. > > Type "less /var/log/mail.log". Then type "/foo", where "foo" is > a regular expression matching whatever you want to highlight, and > hit return. Now type "F". Thanks Logan, I didn't know less could 'follow'. The other solution by Andreas I like because I can run through a script and use 256 colors for all sort of regexes. -- Troy Piggins ,-o o ) Ubuntu linux 6.06 http://ubuntu.com RLU#415538 http://counter.li.org `-o uptime: 19:57:53 up 20 days,1:26,2 users,load average:0.04,0.03,0.00 |
|
#6
| |||
| |||
| The carbonbased lifeform Troy Piggins inspired comp.unix.admin with: > * Logan Shaw wrote: >> Troy Piggins wrote: >>> I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail >>> logs while testing. I was wondering if there is any tools >>> similar that might have the ability to color keywords (maybe >>> based on REs)? This would help certain keywords stand out more. >> >> Type "less /var/log/mail.log". Then type "/foo", where "foo" is >> a regular expression matching whatever you want to highlight, and >> hit return. Now type "F". > > Thanks Logan, I didn't know less could 'follow'. > > The other solution by Andreas I like because I can run through a > script and use 256 colors for all sort of regexes. Or use e.g. http://www.vanheusden.com/multitail/ , or http://lofimo.anzac.at/ or another log-analyser Theo -- theo at van-werkhoven.nl ICQ:277217131 SuSE Linux linuxcounter.org: 99872 Jabber:muadib at jabber.xs4all.nl AMD XP3000+ 1024MB "ik _heb_ niets tegen Microsoft, ik heb iets tegen de uitwassen *van* Microsoft" |
|
#7
| |||
| |||
| * Theo v. Werkhoven wrote: > The carbonbased lifeform Troy Piggins inspired comp.unix.admin with: >> * Logan Shaw wrote: >>> Troy Piggins wrote: >>>> I'm using 'tail -f /var/log/mail.log' to keep an eye on my mail >>>> logs while testing. I was wondering if there is any tools >>>> similar that might have the ability to color keywords (maybe >>>> based on REs)? This would help certain keywords stand out more. >>> >>> Type "less /var/log/mail.log". Then type "/foo", where "foo" is >>> a regular expression matching whatever you want to highlight, and >>> hit return. Now type "F". >> >> Thanks Logan, I didn't know less could 'follow'. >> >> The other solution by Andreas I like because I can run through a >> script and use 256 colors for all sort of regexes. > > Or use e.g. http://www.vanheusden.com/multitail/ , or > http://lofimo.anzac.at/ or another log-analyser That's it! THankyou. -- Troy Piggins ,-o o ) Ubuntu linux 6.06 http://ubuntu.com RLU#415538 http://counter.li.org `-o uptime: 09:43:19 up 20 days,15:12,2 users,load average:0.00,0.01,0.00 |
|
#8
| |||
| |||
| For bash I was not able to use the parameters for an alias. Therefor I created a function: t() { tail -f -n5000 $1 | perl -pe "s/$2/\e[1;31;43m$&\e[0m/g" } This function will tail the file given as parameter 1 and highlight the text given as parameter 2. Example: t myLog.log INFO Martijn de Bruijn |
« Previous Thread
|
Next Thread »
| Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert 8Bits RGB Pixels to Palette Color Index and Color LUTs for Icon Image Seqence | santhilak | DICOM | 0 | 07-01-2009 04:28 PM |
| COLOR changes color of entire screen | unix | MS-DOS | 9 | 11-05-2008 12:02 PM |
| HP OJ d145 color ink out error replace color ink cartridge message | unix | Hewlett Packard | 32 | 10-04-2007 11:57 PM |
| [TC] How to use color constant ( >=8 ) as background color ? | unix | MS-DOS | 5 | 10-01-2007 06:11 AM |
| Howto change the font color of just a certain website to my choice of color? | unix | Mozilla | 13 | 05-16-2006 08:05 AM |
All times are GMT. The time now is 09:37 AM.
