![]() |
| ||
| Using color escape codes in less 1 Attachment(s) Hi all, Please forgive me if you saw this post in other forums as well. I just do not seem to get any answer.... A. My Environment ============== I am using RedHat Linux, version 2.6.18-53.el5. When I type less --version I get: less 394 Copyright © 1984-2005 Mark Nudelman ... My terminal is configured as Xterm, using ANSI colors and indeed, typing ls --color=yes produces a colored list. B. Background =========== I am using a small pearl script that colors lines of text according to predefined key words. This is a very nice utility. When I redirect tail -f output to it, it produces nice color logs of my server, with words such as "Exception" or "Error" conveniently colored. Recently I wanted to try a more ambitious use of this script: To use it together with less command. Anyone can understand, that less +F is better than tail -f, as one can press CTRL+C at any given time when viewing a file online, and scroll or search within it effortlessly, without ever returning to the shell prompt. Which leads me to: C. The Problem =========== 1. I can not get less to show color. Even typing "ls --color=yes > test.txt" and then less -r text.txt or less -R text.txt NEVER displays the content in color. The output is actually the same as doing a "ls --color=no" 2. I read a bit about less input preprocessor the related Environment Variables in UNIX man pages : less (). 3.But, I can not figure out how I can turn less to use colors on a regular basis, How I can make less to "relay" all its output through my color pearl script, and mostly - Is it possible at all? Any help would be highly appreciated. Attached are my colorlogs.pl and colorlogs.conf files, to complement this post. Thank you in advance. |
| ||
| Re: Using color escape codes in less OK. At last, success. This is the only thing that is working, 100% to my satisfaction. nohup less +F /var/log/Server.log | /usr/local/src/Colorlogs/colorlogs.pl > takethis.log & less +F -f -R takethis.log This works wonderfully. |
| All times are GMT -4. The time now is 9:42 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC