Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.
Thank you in advance.

This is out of my area, but I did see this link about setting up less with git:
http://rha7dotcom.blogspot.com/2008...
Maybe it'll give you some ideas.

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.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |