Computing.Net > Forums > Unix > Highlighting words in unix

Highlighting words in unix

Reply to Message Icon

Original Message
Name: deeps
Date: February 12, 2003 at 08:19:50 Pacific
Subject: Highlighting words in unix
OS: Sun OS 5.8
CPU/Ram: sun4u sparc SUNW, sun-fir
Comment:

Hi,
Can anyone help me find out how to highlilght certain words in unix. I know of a command "smso" and it usage also. But, i am unable to recall, that with a combination of some control characters, we can also highlight text in unix. This works on HP-UX or SVR4.
Doesn anyone use them in their .profile files or shell scripts to highlight a particular point.

Thanks..


Report Offensive Message For Removal


Response Number 1
Name: WilliamRobertson
Date: February 13, 2003 at 06:14:18 Pacific
Subject: Highlighting words in unix
Reply: (edit)

I use:

export BOLD=$(tput bold)
export REV=$(tput rev)
export CLEAR=$(tput sgr0)
export HOSTNAME=$(hostname)
PS1="${BOLD}${HOSTNAME} ${CLEAR}\${PWD}: "

However the results will depend on the terminal application. e.g. Hummingbird HostExplorer lets you assign colours to bold, underline etc, so I have separate definitions set up for dev and production servers with different coloured prompts.


Report Offensive Follow Up For Removal

Response Number 2
Name: Jerry Lemieux
Date: February 13, 2003 at 06:43:09 Pacific
Subject: Highlighting words in unix
Reply: (edit)

If what you are looking for is the ANSI escape sequences, try this:

tput bold > bold

What you will see in the file is something like:

^[[1m

If you want to type the sting into a file, use v which will create the ^[ and then type in [1m and you will have the sequence. You can see other sequences such as tput sgr0 in the same manner and then use them in a print statement. William Robertson's suggestion is how I do it and is actually the best way, in my opinion.


Report Offensive Follow Up For Removal

Response Number 3
Name: deeps
Date: February 13, 2003 at 08:52:52 Pacific
Subject: Highlighting words in unix
Reply: (edit)

Many Many thanks to William & Jerry too...

Helped a great deal......... :-)


Report Offensive Follow Up For Removal

Response Number 4
Name: Jerry Lemieux
Date: February 13, 2003 at 09:25:57 Pacific
Subject: Highlighting words in unix
Reply: (edit)

That v in my response was a CNTL v then Esc. I made the mistake of putting the CNTL and the Esc between angle brackets which causes them not to appear in the posting.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Highlighting words in unix

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge