Operating System - HP-UX
1831915 Members
3239 Online
110031 Solutions
New Discussion

Re: Keywords patterns with different colors

 
siulogoid
Occasional Contributor

Keywords patterns with different colors

Hello,

 

 

 

does anyone can tell me if this is possible and if it is how?

 

 

I would like to set groups of keywords and set color for each group, so everytime I ran grep;cat; more; tail I can quickly see the words.

 

 

for example

a critical group with words like: "error"; "exception"; "NOK" as red

warning group as orange or yellow: "warning"; "advise"; "incorrect"

and other group green: "correct"; "OK"

 

 

 

I've seen this working in IBM AIX, but don't know how neither if it is possible in HP-UX

 

 

 

Thanks,

 

 

Diogo Rodrigues

 

 

P.S. This thread has been moved from HP-UX > Training & Education to HP-UX > languages. - Hp Forum Moderator

1 REPLY 1
Bill Hassell
Honored Contributor

Re: Keywords patterns with different colors

Nothing like that in HP-UX.

You would first have to determine what type of terminal you are using, as in:

 

Does it support color? There are HUNDREDS of terminal types listed in /usr/lib/terminfo. A vt100 terminal never had any color except white. If you are not using a real terminal, but a terminal emulator on a PC such as PuTTY or Reflection or hpterm or xterm, etc, then check to see whether there are color enhancements available. Some terminal emulators support ANSI colors, many do not, specfically HP terminals and emulators which have proprietary color codes.

 

If there are color enhancements available, many (not all) of the terminals listed in terminfo have their escape sequences defined in the terminfo files. You'll need to read the document: man terminfo to find the various color codes (Cap name), then use the tput command to form the sequence to start a color and then end a color.

 

Once you've got the color selection codes, you would then have to wrapper all the output sent to your screen to look for the keywords and insert the codes before and after each word.

 

And of course, this feature will be restricted to terminals that correctly identify themselves (ie, forcing TERM=vt100 is a bad idea).

 



Bill Hassell, sysadmin