Bold Characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bold Characters
# 1  
Old 10-15-2009
Bold Characters

Hi All,

How to make the characters bold in k shell.

like for example

"File is too large to view" to "File is too large to view"

is it like echo "File is too large to view"

Please advice and samples
# 2  
Old 10-15-2009
Hi.

You could try:

Code:
bold=`tput smso`
offbold=`tput rmso`

or
bold=`tput bold`
offbold=`tput sgr0`

Then echo $[bold} to switch it on, and echo ${offbold} to switch it off.

Code:
bold=`tput bold`
offbold=`tput sgr0`

echo "This word is ${bold}bold${offbold} and this is not"


This word is bold and this is not

How it works depends on your terminal capabilities.

Code:
man tput

# 3  
Old 10-15-2009
Quote:
Originally Posted by scottn
Hi.

You could try:

But there is no guarantee that it will work.

There are two different versions of tput; one uses the terminfo database, the other the termcap database.

As I wrote in Pro Bash Programming (publication date is next Monday, Oct. 19):

Unix purists will shake their heads over this chapter. Traditionally, screen manipulation is done through the termcap or terminfo database that supplies the information necessary to manipulate any of dozens or even hundreds of types of terminal. The shell interface to the database is an external command, tput.

On some systems, tput uses the termcap database; on others (mostly newer systems) it uses the terminfo database. The commands for the two databases are not the same, so a tput command written for one system may not work on another.

On one system, the command to place the cursor at the 20th column on the 10th row is:

tput cup 9 19

On another system, the command is:

tput cm 19 9

These commands will produce the correct output for whatever type of terminal is specified in the TERM variable. (Note: tput starts counting at 0.)

However, the plethora of terminal types has, for all intents and purposes, been reduced to a single, standard type. This standard, ISO 6429 (also known as ECMA-48, and formerly known as ANSI X3.64 or VT100), is ubiquitous, and terminals that do not support it are few and far between. As a result, it is now feasible to code for a single terminal type. One advantage of this homogeneity is that the necessary coding can be done entirely within the shell. There's no need for an external command.
This is the code to use:

Code:
printf "\e[1m"  ## bold on
printf "\e[0m"  ## bold (and other attributes) off

# 4  
Old 10-20-2009
Hi,

It not working it is giving me unusually result. please find below

This word is  bold  and this is not

It is not making bold as bold

i am using k shell.

Please advice

Thanks
Rajesh
# 5  
Old 10-20-2009
As I already replied in a different thread you wrongly open, there is no standard way to achieve what you want. That will mainly depends on how you view the file. ksh or any other shell is irrelevant.
# 6  
Old 10-20-2009
What happens if you use tput smso and tput rmso?
# 7  
Old 10-20-2009
fpmurphy, I'm afraid you are missing the issue is not that much the encoding but how the file is viewed.
"cat", "less -r" should work assuming the terminal emulator is complying but "less", "vi" and other editing commands will lead to what the OP experiments.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help getting rid of bold characters

Hi! So i've got this shell script that asks questions and the user is required to input answers. The answers typed are bold. sh-*.*$ sh filename dir cat question tput bold read ans tput sgr0 ... and so on tput sgr0 exit So when the script ends i don't get the bold characters... (3 Replies)
Discussion started by: Kingzy
3 Replies

2. Shell Programming and Scripting

Making Some Characters in file BOLD

Hi All, I want to make some characters to be bold in a file. I have a file e.g aa.log which contains rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr gfgfgdaerqrqwrqerqwrwqwrqrqwrqr qqwerqwrqwrqwrqwrqwrqwrqwrq qwrqwrqwrqwrqwrqwrqwrqwrqwr File is too large to view Last line... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

3. Shell Programming and Scripting

how to display in bold

Hi, i am using mailx option to send mail from unix In the body of the mail i want certain numbers to be displayed in bold Is there any way to do it If so, can anyone help me in this regard. (2 Replies)
Discussion started by: trichyselva
2 Replies

4. Shell Programming and Scripting

Bold characters in a file using Shell script

Hi, When I am running below mentioned script then the characters become bold but after opening the same file in Windows, Instead of getting bold characters i am getting some garbage value for \033Kunal Dixit Output in Windows (after ftp the file): but in windows , i am getting My name is... (0 Replies)
Discussion started by: kunal_dixit
0 Replies

5. UNIX and Linux Applications

Bold characters in mail

I sh, I have bold characters in a file and I want to mail file to an ID. $cat file Incorrect or invalid external email IDs in TO and CC list for email_rules: If I pass this file to mailx $ cat file | mailx -s "hi" abc@xyz.com What I get in mail is  (8 Replies)
Discussion started by: hemangi13
8 Replies

6. Shell Programming and Scripting

Bold characters in c shell

Hi, Can someone tell me how to display characters in Bold in C shell?? (9 Replies)
Discussion started by: hemangi13
9 Replies

7. Shell Programming and Scripting

color,bold

hi friend , I am generating a csv file i,e output file E104|0|06/04/1994|The values E005 and E001 are not equal. E106|0|01/09/1993|The values E001 and E002 are not equal. E106|0|01/09/1993|The values E003 and E002 are not equal. E108|0|02/30/1995|The values R001 and E001 are not equal.... (0 Replies)
Discussion started by: charandevu
0 Replies

8. Programming

Bold text

hello, how do i display the text in the printf statement in bold. or is there anyway to display the text on the console in bold thx in advance svh (3 Replies)
Discussion started by: svh
3 Replies

9. UNIX for Dummies Questions & Answers

Printing in Bold

Hi, How do I print some shell variable in BOLD/ Thanks for any suggestions, Preeti (10 Replies)
Discussion started by: preetikate
10 Replies

10. Shell Programming and Scripting

Bold the paragraph

Hi, I have a file with multiple paragraph. I want to look for some word and make that paragraph bold. How can I do that? Thanks, Karthik (3 Replies)
Discussion started by: caprikar
3 Replies
Login or Register to Ask a Question